Preventing dropdown from hiding without JavaScript - html

An onClick and hover dropdown menu in pure CSS (no JavaScript) displays the items at first, but the menu doesn't stay open when I put my mouse over the dropdown items (but it does stay open onClick).
Here it is:
.acn-menu {
text-align: center;
background-color: rgba(0, 0, 0, 0.9);
}
.label_openclose {
display: none;
}
.menu-tabs {
height: 100%;
padding-left: 0;
padding-right: 0;
padding-top: 0;
padding-bottom: 0;
}
#media (min-width: 320px) {
.menu-tabs {
position: absolute;
}
}
.menu-tabs .elem {
box-sizing: border-box;
padding: 0 20px;
float: left;
height: 100%;
line-height: 70px;
background-color: rgb(30, 30, 30);
color: white;
}
.menu-check {
display: none;
}
label {
margin-bottom: 0;
}
.label_openclose {
display: inline-block;
width: 60px;
min-height: 50px;
background-color: transparent;
cursor: pointer;
overflow:hidden;
display:block;
}
.menu-tabs .elem {
line-height: initial;
float: initial;
height: 0px;
cursor: pointer;
border-top: 0px solid #000;
overflow: hidden;
}
.menu-check:checked~.menu-tabs .elem {
height: 25px;
color: white;
border-top: 2px solid rgba(255, 255, 255, 0.2);
}
.label_openclose:hover~.menu-tabs .elem {
border-top: 2px solid rgba(255, 255, 255, 0.2);
height: 25px;
}
Here is a fiddle:
https://jsfiddle.net/Lwjvwcva/

You have to add a rule that tells the browser to show .menu-tabs while hovering on it, so I added this rule:
.label_openclose~.menu-tabs:hover .elem {
border-top: 2px solid rgba(255, 255, 255, 0.2);
height: 25px;
}
check the updated fiddle here.
hope this helps :)

In order for the submenu to remain open, the item where the submenu sits INSIDE needs to be the one selected on hover. In this case .acn-menu or .nav (I used .nav in my code). To make the hover submenu stay open, I removed and added a few lines in the css:
Removed:
.label_openclose:hover~.menu-tabs .elem {
border-top: 2px solid rgba(255, 255, 255, 0.2);
height: 25px;
}
Added:
.nav .menu-tabs {
display:none;
}
.nav:hover .menu-tabs {
display:block;
}
.menu-tabs .elem {
height:25px;
border-top: 2px solid rgba(255, 255, 255, 0.2);
}

Related

disable click on range input for it's background

I'm trying to create an application that uses spotify's apis, But I'm trying to set an input range thumb track to not 'expand' on click, although this error in the video occurs for some unknown reason.
I tried setting the range pointer-even attributes to things like, "auto" or "none" (with !important as well) but either or don't work. Any help?
Range's CSS:
.container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.box-minmax {
margin-top: 30px;
width: 608px;
display: flex;
justify-content: space-between;
font-size: 20px;
color: #fff;
}
.box-minmax span:first-child {
margin-left: 10px;
}
.range-slider {
margin-top: -2vh;
}
.rs-range {
margin-top: 29px;
margin: 0 auto !important;
width: 300px;
-webkit-appearance: none;
}
.rs-range:focus {
outline: none;
}
.rs-range::-webkit-slider-runnable-track {
width: 50%;
height: 2px;
cursor: pointer;
box-shadow: none;
background: rgb(78, 78, 78);
border-radius: 0px;
border: 0px solid #010101;
pointer-events: auto;
overflow: visible;
}
.rs-range::-moz-range-track {
width: 50%;
height: 2px;
cursor: pointer;
box-shadow: none;
background: rgb(78, 78, 78);
border-radius: 0px;
border: 0px solid #010101;
pointer-events: none;
overflow: visible;
}
.rs-range::-webkit-slider-thumb {
box-shadow: none;
border: 0px solid #fff;
box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.25);
height: 16px;
width: 16px;
border-radius: 22px;
background: rgb(78, 78, 78);
cursor: pointer;
-webkit-appearance: none;
margin-top: -8px;
}
.rs-range::-moz-range-thumb {
box-shadow: none;
border: 0px solid #fff;
box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.25);
height: 16px;
width: 16px;
border-radius: 22px;
background: rgba(255, 255, 255, 1);
cursor: pointer;
-webkit-appearance: none;
margin-top: -8px;
}
.rs-range::-moz-focus-outer {
border: 0;
}
.rs-label {
position: relative;
display: block;
background: transparent;
line-height: 30px;
text-align: center;
margin-left: -255px;
margin-top: 7px;
left: attr(value);
font-size: 15px;
color: rgb(99, 99, 99);
}
HTML:
<form class="range-field w-64">
<div class="range-slider">
<input id="rs-range-line" class="rs-range" type="range" value="0" min="0">
<span id="rs-bullet" class="rs-label">0</span>
</div>
</form>
Video: https://imgur.com/a/IuLaUbb

Trouble Converting ul Dropdown to a Select DropDown

I have a jsfiddle with a dropdown list using ul and li (jsfiddle). When trying to convert this to a select options drop down list I am not getting the same options([jsfiddle])2.
I'm guessing it has to do with the way I renamed some one the CSS (I just replaced li with option) but I'm not sure what is wrong with it. My current HTML and CSS are below and two jsfiddles are in the text up top.
HTML
<div class="dd wrapper-dropdown-3" tabindex="1">
<select id="Process" class="dropdown" name="Process" data-val-required="Required" dataval="true">
<option value="">--- Select One ---</option>
<option value="Extrusion">Extrusion</option>
<option value="Injection">Injection</option>
<option value="Secondary">Secondary</option>
<option value="Vinyl Dip Molding">Vinyl Dip Molding</option>
</select>
</div>
CSS
.wrapper-dropdown-3 {
/* Size and position */
position: relative;
width: 200px;
margin: 0 auto;
padding: 10px;
/* Styles */
background: #fff;
border-radius: 7px;
border: 1px solid rgba(0, 0, 0, 0.15);
box-shadow: 0 1px 1px rgba(50, 50, 50, 0.1);
cursor: pointer;
outline: none;
/* Font settings */
font-weight: bold;
color: #0000FF;
}
.wrapper-dropdown-3:after {
content:"";
width: 0;
height: 0;
position: absolute;
right: 15px;
top: 50%;
margin-top: -3px;
border-width: 6px 6px 0 6px;
border-style: solid;
border-color: #8aa8bd transparent;
}
.wrapper-dropdown-3 .dropdown {
/* Size & position */
position: absolute;
top: 100%;
left: 0;
right: 0;
/* Styles */
background: white;
border-radius: inherit;
border: 1px solid rgba(0, 0, 0, 0.17);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
font-weight: normal;
list-style: none;
/* Hiding */
opacity: 0;
pointer-events: none;
/*Gets rid of the padding where the bullets would be*/
padding-left:0;
}
.wrapper-dropdown-3 .dropdown option a {
display: block;
padding: 10px;
text-decoration: none;
color: #0000FF;
border-bottom: 1px solid #e6e8ea;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 1);
transition: all 0.3s ease-out;
}
.wrapper-dropdown-3 .dropdown option i {
float: right;
color: inherit;
}
.wrapper-dropdown-3 .dropdown option:first-of-type a {
border-radius: 7px 7px 0 0;
}
.wrapper-dropdown-3 .dropdown option:last-of-type a {
border-radius: 0 0 7px 7px;
border: none;
}
/* Hover state */
.wrapper-dropdown-3 .dropdown option:hover a {
background: #f3f8f8;
}
.wrapper-dropdown-3 .dropdown:after {
content:"";
width: 0;
height: 0;
position: absolute;
bottom: 100%;
right: 15px;
border-width: 0 6px 6px 6px;
border-style: solid;
border-color: #fff transparent;
}
.wrapper-dropdown-3 .dropdown:before {
content:"";
width: 0;
height: 0;
position: absolute;
bottom: 100%;
right: 13px;
border-width: 0 8px 8px 8px;
border-style: solid;
border-color: rgba(0, 0, 0, 0.1) transparent;
}
.wrapper-dropdown-3.active .dropdown {
opacity: 1;
pointer-events: auto;
}
You need to do a couple of things to fix your problem. All of these are inside your .wrapper-dropdown-3 .dropdown styling. First, remove pointer-events: none as #ramesh mentioned. Then change your top: 100%; to top: 0;. Add width: 100%;. Change opacity: 0; to opacity: 1; so that you can see it. Remove your border, selects already have a border. And lastly, add the following to remove the default dropdown arrow from Firefox:
-moz-appearance: none;
text-indent: 0.01px;
text-overflow: '';
Here is an updated JSFiddle.
pointer-events: none; was causing the issue. Replace the following class with the css provided:
.wrapper-dropdown-3 .dropdown {
position: absolute;
width: 100%;
top: 0;
left: 0;
right: 0;
background: white;
border-radius: inherit;
border: 1px solid rgba(0, 0, 0, 0.17);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
font-weight: normal;
list-style: none;
opacity: 0;
padding-left: 0;
}
Not sure why you had a pointer-event there, because it kind of doesn't allow you to interact with the element.

Selection Options not Formatting

I have some code that produces a Drop Down List using ul and li Here is the first jsfiddle. This is how I would like my drop downs to look. However when I try and convert them to a select and options drop down list I am receving the following format, current jsfiddle. All I did was replace the li in the first fiddle with option. Any ideas how to fix this or why it's doing this? It seems like it is ignoring everything I replaced
Current HTML
<select class="wrapper-dropdown-3 dropdown" name="Process" data-val-required="Required" dataval="true">
<option value="">--- Select One ---</option>
<option value="Extrusion">Extrusion</option>
<option value="Injection">Injection</option>
<option value="Secondary">Secondary</option>
<option value="Vinyl Dip Molding">Vinyl Dip Molding</option>
</select>
Current CSS
.wrapper-dropdown-3 {
/* Size and position */
position: relative;
width: 200px;
margin: 0 auto;
padding: 10px;
/* Styles */
background: #fff;
border-radius: 7px;
border: 1px solid rgba(0, 0, 0, 0.15);
box-shadow: 0 1px 1px rgba(50, 50, 50, 0.1);
cursor: pointer;
outline: none;
/* Font settings */
font-weight: bold;
color: #0000FF;
}
.wrapper-dropdown-3:after {
content:"";
width: 0;
height: 0;
position: absolute;
right: 15px;
top: 50%;
margin-top: -3px;
border-width: 6px 6px 0 6px;
border-style: solid;
border-color: #8aa8bd transparent;
}
.wrapper-dropdown-3 .dropdown {
/* Size & position */
position: absolute;
width: 100%;
height:100%;
top: 0;
left: 0;
right: 0;
/* Styles */
background: white;
border-radius: inherit;
border: 0px solid rgba(0, 0, 0, 0.17);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
font-weight: normal;
list-style: none;
/* Hiding */
opacity: 1;
/*Gets rid of the padding where the bullets would be*/
padding-left:0;
-moz-appearance: none;
-webkit-appearance:none;
text-indent: 0.01px;
text-overflow:'';
}
.wrapper-dropdown-3 .dropdown option a {
display: block;
padding: 10px;
text-decoration: none;
color: #0000FF;
border-bottom: 1px solid #e6e8ea;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 1);
transition: all 0.3s ease-out;
}
.wrapper-dropdown-3 .dropdown option i {
float: right;
color: inherit;
}
.wrapper-dropdown-3 .dropdown option:first-of-type a {
border-radius: 7px 7px 0 0;
}
.wrapper-dropdown-3 .dropdown option:last-of-type a {
border-radius: 0 0 7px 7px;
border: none;
}
/* Hover state */
.wrapper-dropdown-3 .dropdown option:hover a {
background: #f3f8f8;
}
.wrapper-dropdown-3 .dropdown:after {
content:"";
width: 0;
height: 0;
position: absolute;
bottom: 100%;
right: 15px;
border-width: 0 6px 6px 6px;
border-style: solid;
border-color: #fff transparent;
}
.wrapper-dropdown-3 .dropdown:before {
content:"";
width: 0;
height: 0;
position: absolute;
bottom: 100%;
right: 13px;
border-width: 0 8px 8px 8px;
border-style: solid;
border-color: rgba(0, 0, 0, 0.1) transparent;
}
.wrapper-dropdown-3.active .dropdown {
opacity: 1;
pointer-events: auto;
}
You have specified a class name = "wrapper-dropdown-3 drop down" however there is no part of your CSS that styles this class. Also, you should pay attention to your HTML DOM structure when styling in CSS. For example in the code:
<ul class="ul">
<li class="li"></li>
</ul>
You would have a CSS like:
.ul{/*CSS code*/}
and
.ul .li{/*CSS code*/}
and not
.li{/*CSS code*/}
since the li tag is within the ui tag

nth-child() pseudo class on <a> tags

I've been creating a new header design for my site and all but one issue is resolved. For some reason, when i try using the nth-child(1) or first-child or last-child on the class navLink it applies the rules to ALL the links, rather than the selected element. I'll post some code below with a jsfiddle to demonstrate my point.
http://jsfiddle.net/rg7fe/
HTML
<ul id="nav">
<li class="navItem"><a class="navLink" href="#">Test</a></li>
</ul>
CSS
#nav {
background: RGB(200, 230, 240);
border-bottom: 1px solid RGB(0, 0, 0);
height: 30px;
margin: 0 auto;
position: relative;
width: 980px;
z-index: 5;
}
.navItem {
display: block;
float: left;
position: relative;
}
.navLink:first-child {
border-left: 1px solid RGB(0, 0, 0);
}
.navLink {
border-bottom: 1px solid RGB(0, 0, 0);
border-right: 1px solid RGB(0, 0, 0);
display: inline-block;
height: 30px;
line-height: 30px;
padding: 0 15px;
white-space: nowrap;
}
.navItem:hover .navLink {
background: RGB(120, 200, 250);
color: RGB(255, 255, 255);
}
You need to apply nth-child to <li> not <a> which are always first, last and number one child in <li> .
.navItem:first-child a{
border-left: 1px solid RGB(0, 0, 0);
}
.navItem a{
border-bottom: 1px solid RGB(0, 0, 0);
border-right: 1px solid RGB(0, 0, 0);
display: inline-block;
height: 30px;
line-height: 30px;
padding: 0 15px;
white-space: nowrap;
}
.navItem:first-child .navLink {
border-left: 1px solid RGB(0, 0, 0);
}
use it.
The problem with your method is that .navLink:first-child is calculating first child relative to .navItems which are all items. Hope you got the point.

CSS Problems- header buttons and width

I have problems with the header buttons (on hover) and the body width that I want to make 100%.
Please help.
thank you.
here is the css, you can see the html in jsfiddle.
body {
background-color:rgba(0, 0, 0, 0.1);
font-family: "Alef Hebrew",
“Helvetica Neue”,
Helvetica,
Arial,
sans-serif;
}
#header {
left: 0;
top: 0px;
width: 100%;
height: 64px;
background: #007ac1;
position: fixed;
}
#header ul {
margin-left: 200px !important;
}
#x {
border-left: 1px solid rgba(0, 0, 0, 0.1);
box-shadow: 0px -1px 0px 1px rgba(255, 255, 255, 0.11);
text-decoration: underline;
}
.btn {
margin-left: -2px;
border-right: 1px solid rgba(0, 0, 0, 0.1);
box-shadow: 1px 0 0 rgba(255, 255, 255, 0.11);
color: white;
display: inline;
text-decoration: none;
padding: 25px;
transition: 0.5s;
font-weight:bold;
}
.btn:hover {
background: rgba(255,255,255,1);
color: #000;
}
#body {
padding: 100px;
width: 100%;
background: #fff;
float:left;
}
http://jsfiddle.net/EuR8s/
DEMO
CSS:
#header ul {
margin-left: 100px !important;
}
changed the margin-left: to 100px