Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Pure CSS Dropdown #126

Closed
green3g opened this issue Dec 7, 2016 · 8 comments
Closed

Suggestion: Pure CSS Dropdown #126

green3g opened this issue Dec 7, 2016 · 8 comments

Comments

@green3g
Copy link

green3g commented Dec 7, 2016

What do you think about adding a pure-css dropdown component? This component example is toggled using the :focus selector.

css

.dropdown-menu {
    display: none;
    position: absolute;
}
a.dropdown-toggle:focus,
a.dropdown-toggle:active {
    background: #f2f2f2;
}
a.dropdown-toggle:focus+.dropdown-menu,
a.dropdown-toggle:active+.dropdown-menu {
    display: block;
}
.dropdown-menu:hover {
    display: block;
}

example:

    <div class="dropdown float-left">
        <a href="#" onclick="javascript:return false;" class="btn btn-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true">Dropdown Menu
          <i class="caret fa fa-caret-down"></i>
        </a>
        <ul class="dropdown-menu menu">
                <li class="menu-item">
                    <a href="#">
                        <i class="fa fa-fw fa-map-marker"></i> Dropdown Item 1</a>
                </li>
                <li class="menu-item">
                    <a href="#">
                        <i class="fa fa-fw fa-map-marker"></i> Dropdown Item 2</a>
                </li>
                <li class="menu-item">
                    <a href="#">
                        <i class="fa fa-fw fa-map-marker"></i> Dropdown Item 3</a>
                </li>
        </ul>
    </div>

It looks something like this:
image

@scriptsdemostack
Copy link

looks really nice 👍

@picturepan2
Copy link
Owner

@roemhildtg Thanks, I will consider this component with pure CSS.

@picturepan2
Copy link
Owner

@roemhildtg I tried pure CSS dropdown menu. But the toggle button with :focus is not supported in Firefox and Safari in macOS. Though it can be workable with a hidden radio solution, it is not a best practice.
image

@green3g
Copy link
Author

green3g commented Dec 10, 2016

@picturepan2 I figured there would be a catch 😉

@picturepan2
Copy link
Owner

@roemhildtg It works when I add tabindex to the button elements.

@green3g
Copy link
Author

green3g commented Dec 26, 2016

👍 thanks for the update, good to know!

@picturepan2
Copy link
Owner

@roemhildtg Spectre.css now provides pure CSS dropdown menu. https://picturepan2.github.io/spectre/#dropdowns

@green3g
Copy link
Author

green3g commented Jan 1, 2017

That is awesome! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants