CSS drop-down transition doesn't work - html

I want to make a drop-down menu transition, but it doesn't work at all. Other transitions work just fine but this one is really stubborn. What exactly am I doing wrong ?
In this example, the drop-down does not transition when it is shown:
a {
color: #FFF;
text-decoration: none;
}
li {
height: 20px;
padding-top: 7px;
padding-bottom: 7px;
padding-left: 5px;
padding-right: 5px;
font-size: 17px;
color: #FFF;
display: inline-block;
vertical-align: top;
background-color: #4CA0DB;
}
li:hover {
transition: all 0.3s;
background-color: #4CA0DB;
}
.carret {
position: relative;
margin-left: 5px;
bottom: 1px;
font-size: 12px;
}
/*this is where it breaks*/
.menu-hover ul li {
display: none;
}
.menu-hover:hover ul li {
background-color: #4CA0DB;
display: block;
}
.menu-hover ul {
transition: all 0.3s ease;
}
<nav>
<ul>
<li class="menu-hover">ABOUT THE UNIVERSITY<span class="carret">▼</span>
<ul class="dropdown">
<li>
За нас</li>
<li>
Професии</li>
<li>
Планове</li>
<li>
Специалности</li>
<li>
Преподаватели</li>
<li>
Финансиране</li>
<li>
Кандидатстване</li>
</ul>
</li>
</ul>
</nav>

I finally got it working by using visibility: hidden and visibility: visible instead of display: none and display: block. Thanks for the help! This is how it looks now:
.menu-hover ul li {
display: block;
visibility: hidden;
}
.menu-hover:hover ul li {
background-color: #4CA0DB;
visibility: visible;
transition: all 0.3s ease;
}

Related

CSS-only dropdown mega menu with hover delay

I have a CSS only dropdown mega menu. Now I need to add delay on hover, but only when not already hovering a tab. The goal is to remove the delay before showing subsequent sheets - without using JavaScript. It may or or may not be possible. I have tried using sibling selector to set zero transition delay on the neighbour of the hovered element - this naturally doesn't work because the transition delay rule applies to the 'to' hover state, not the 'from' state.
body * {
outline: 1px solid black;
background-color: #0001;
}
ul {
margin: 0;
padding: 10px;
display: inline-flex;
}
li {
display: inline-block;
padding: 10px;
}
ul li div {
position: absolute;
background-color: white;
width: 200px;
height: 200px;
visibility: hidden;
transition: visibility 0s;
transition-delay: 300ms;
}
ul li:hover button {
background-color: blue;
color: white;
}
ul li:hover div {
visibility: visible;
}
ul li:not(:hover) div {
transition-delay: 0s;
}
a {
padding: 10px;
display: block;
}
a:hover {
text-decoration: none;
}
<ul>
<li>
<button>Link</button>
<div>Sheet</div>
</li>
<li>
<button>Link</button>
<div>Sheet</div>
</li>
</ul>
<a href='#'>Background link</a>
Is this what you want. adding transition delay on the hover state not the actual element css
ul li:hover div{visibility: visible;transition-delay: 1000ms;}
body * {
outline: 1px solid black;
background-color: #0001;
}
ul {
margin: 0;
padding: 10px;
display: inline-flex;
}
li {
display: inline-block;
padding: 10px;
}
ul li div {
position: absolute;
background-color: white;
width: 200px;
height: 200px;
visibility: hidden;
transition: visibility 0s;
}
ul li:hover button {
background-color: blue;
color: white;
}
ul li:hover div {
visibility: visible;
transition-delay: 1000ms;
}
ul li:not(:hover) div {
transition-delay: 0s;
}
a {
padding: 10px;
display: block;
}
a:hover {
text-decoration: none;
}
<ul>
<li>
<button>Link</button>
<div>Sheet</div>
</li>
<li>
<button>Link</button>
<div>Sheet</div>
</li>
</ul>
<a href='#'>Background link</a>

Underline hover is underlining extra

Here's the code I have problem with my underline hover effect its exppanding extra how to fix it please help me out ************************
HTML
<div class="nav-wrap">
<ul class="group" id="example-one">
<li>Home</li>
<li><a class="dropbtn">Models</a>
<ul class="dropdown-content">
<li></li>
<li>Audi</li>
<li>Bmw</li>
<li>Mercedes</li>
</ul>
</li>
<li>Offers</li>
<li>Group Sales</li>
<li>Reviews</li>
</ul>
</div>
And also i want my dropdown in the middle of his parent And here its*********
CSS
.nav-wrap {
background: white;
width: 100%;
}
#example-one {
text-align: right;
}
#example-one li {
text-align: left;
position: relative;
display: inline-block;
font-family: 'Montserrat', sans-serif;
top:-20px;
}
#example-one a {
color: #000;
font-weight: bold;
font-size: 14px;
padding: 15px 15px;
text-decoration: none;
position: relative;
color: #000;
}
#example-one a:after {
color: #333;
content: '';
position: absolute;
width: 0;
height: 3px;
display: block;
margin-top: 2px;
right: 0;
background: #000;
transition: width all 1s ease;
-webkit-transition: width 1s ease;
}
#example-one a:hover:after {
width: 100%;
left: 0;
background: #000;
}
.dropdown-content {
display: none;
position: absolute;
top: 30px;
left: 0;
background-color:white;
z-index: 1;
}
.dropdown-content a {
color: black;
text-decoration: none;
display: block;
}
#example-one li li {
display: block;
}
#example-one li:hover>ul {
display: block;
}
If I understand your problem correctly, the issue is with the dropdown items not being centered and the dropdown underline being too long. I believe this issue is caused by the padding on the dropdown div.
To resolve this, add some normalised padding to your .dropdown-content class:
.dropdown-content {
padding: 0 20px;
}
let the underline be attached to the text it self not to all the list item so it takes the width of just the text, now it takes the width of the whole cell in the list

Button in CSS3 not clickable

I want to make some fancy social buttons with Font Awesome, CSS3 and lists in HTML. It should look like this. But now it is not possible to click on the anchor (a-tag).
How can I accomplish this?
ul {
list-style: outside none none;
}
ul li {
display: block;
float: left;
background-color: #099;
margin-right: 10px;
padding: 10px 0px;
text-align: center;
width: 40px;
opacity: 0.2;
transition: all 0.2s ease-in-out 0s;
}
li::before {
color: #FFF;
font-size: 35px;
}
ul li a {
color: transparent;
font: 0px/0 a;
white-space: nowrap;
}
ul li:hover {
opacity: 1;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
<ul id="menu-social" class="menu">
<li id="menu-item-googleplus" class="fa fa-google-plus menu-item menu-item-googleplus">
Google+
</li>
<li id="menu-item-facebook" class="fa fa-facebook menu-item menu-item-facebook">
Facebook
</li>
</ul>
Add position relative to the li elements and then stretch the anchor.
ul li {
display: block;
float: left;
background-color: #099;
margin-right: 10px;
padding: 10px 0px;
text-align: center;
width: 40px;
opacity: 0.2;
transition: all 0.2s ease-in-out 0s;
/* Add position */
position:relative;
}
ul li a {
color: transparent;
font: 0px/0 a;
white-space: nowrap;
/* Stretch a element */
position: absolute;
left:0;
top:0;
width:100%;
height: 100%;
}

parent item drop up with sub menu

hello is it possible that when I hover to the parent item the parent item will also slide up making the drop down menu with parent item above it? here is my code but I cant seem to make it work. here is a visual menu that i want http://imgur.com/om9mvdG (the second image)
.nav ul {
*zoom: 1;
list-style: none;
margin: 0;
padding: 0;
background: #333;
}
.nav ul:before,
.nav ul:after {
content: "";
display: table;
}
.nav ul:after {
clear: both;
}
.nav ul > li {
float: left;
position: relative;
}
.nav a {
display: block;
padding: 10px 20px;
line-height: 1.2em;
color: #fff;
border-left: 1px solid #595959;
}
.nav a:hover {
text-decoration: none;
background: #595959;
}
.nav li ul {
background: #273754;
position: absolute;
left: 0;
bottom: 36px;
z-index: 1;
}
.nav li ul li {
width: 100%;
overflow: hidden;
height: 0;
-webkit-transition: height 200ms ease-in;
-moz-transition: height 200ms ease-in;
-o-transition: height 200ms ease-in;
transition: height 200ms ease-in;
}
.nav li ul a {
border: none;
}
.nav li ul a:hover {
background: rgba(0, 0, 0, 0.2);
}
.nav ul > li:hover ul li {
height: 36px;
}
<ul>
<li>
Nav Item
<ul>
<li>Subnav
</li>
<li>Subnav
</li>
<li>Subnav
</li>
</ul>
</li>
<li>
Nav Item
<ul>
<li>Subnav
</li>
<li>Subnav
</li>
<li>Subnav
</li>
</ul>
</li>
</ul>
</nav>
Add this css to your already existing code. Is this what you wanted?
http://codepen.io/anon/pen/jbBgdg
li>ul {
display: none;
}
a:hover~ul {
display: block;
}

How can I make the background of an li the same length as the text in it?

I have the following HTML:
<div id="resultList">
<ul>
<li class="product"> Hevea fopspeentje Kroon
</li>
<li class="product"> BabyBjörn Babybord met babylepel 2-Pack
</li>
<li class="product"> Janod Scooter Vanilla
</li>
<li class="product"> Numi-Med Medicijnspeen met doseerschijf Wit (6-18 mnd)
</li>
</ul>
</div>
and CSS:
#resultList {
max-width: 557px;
margin-top: 13px;
padding: 20px;
border: 4px solid #c7c6c6;
border-radius: 4px;
background: #ffffff;
}
#resultList a {
padding: 8px 14px;
color: #072f49;
text-decoration: none;
display: block;
}
#resultList ul li {
margin-bottom: 10px;
color: #072f49;
list-style: none;
background: #f5f5f5;
display: inline-block;
-webkit-transition: background 0.3s ease;
-moz-transition: background 0.3s ease;
-o-transition: background 0.3s ease;
transition: background 0.3s ease;
}
#resultList .product {
width: 100%;
display: inline-block;
}
and the jsFiddle
I would like each product do be on a different line. That is why I set #resultList .product to width:100; However, I would like the background of the #resultList ul li to only be as long as the text itself.
Is there a way to do this?
Move the background-color to the <a> element inside the <li>.
http://jsfiddle.net/NicoO/7nR7T/4/
#resultList ul li {
margin-bottom: 10px;
list-style: none;
display: block;
}
#resultList .product A {
color: #072f49;
background: #f5f5f5;
display: inline-block;
}
add background css code for a and remove background in li. Demo
#resultList a {
background:#F5F5F5;
color: #072F49;
display: block;
float: left;
padding: 8px 14px;
text-decoration: none;
}
#resultList ul li {
margin-bottom: 10px;
list-style: none;
display: inline-block;
}
You can make the width:inherit instead of setting to 100% in #resultList .product.
Updated fiddle. DEMO.