Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for How they made controls at Github? Popup
Kiran Mantha
Kiran Mantha

Posted on • Edited on

     

How they made controls at Github? Popup

Recap

In last episode we gone through creation of hamburger menu with details and summary tags.

Now

This is the last episode of this series which walks through creation of popups using these wonderful tags.

Asusual let's start with same boring repeatitive html

<detailsaria-haspopup="true"><summary>        I'm a popcorn</summary><div>You are awesome!!</div></details>
Enter fullscreen modeExit fullscreen mode

ahhhh popcornnn it's movie time...😃 wait that's a stupid accordion...😬

ok ok i saw your frustation.. take a drink

you know what, we don't have to start from scratch for this. Popup is same as that of dropdown which we designed in1st episode.

The difference is:

  1. Popup can contain any type of content whereas a dropdown contain a list of options.
  2. It is an in-line element unlike dropdown which is a block element.

so we can reuse dropdown styles(well we don't need most of them) which looks like:

:root{--primary:#fff;--border-color:#ccc;--spacing:1rem;}details[aria-haspopup="true"]{position:relative;&>summary{list-style:none;}&[open]>summary{&::before{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1;display:block;cursor:default;content:' ';background:transparent;}}}
Enter fullscreen modeExit fullscreen mode

There it is. The basic structure is done. Click anywhere on the page, the accordion will close. Now lets add simple styles to containerdiv tag.

summary+div{position:absolute;margin:4pxauto;padding:var(--spacing);z-index:2;background-color:var(--primary);border:1pxsolidvar(--border-color);border-radius:4px;}
Enter fullscreen modeExit fullscreen mode

Awesome!! right?? click onsummary tag, it will open a small popup sayingYou are awesome yes i mean it. you really are!!

By applyingleft,right orbottom css todiv tag, you can position the popup in any direction.

And that's it. There's your Popcorn.. ohh i mean Popup 😄

Thanks for your time andhere is the working example.

See you again ✌️,
Kiran 👋

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

A playful father and developer. Creator of PlumeJS a webcomponent & typescript based framework to build SPAs
  • Location
    Bangalore
  • Work
    Senior Dev at PublicisSapient
  • Joined

More fromKiran Mantha

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp