I am trying to set behaviour for menu items in the header like here: http://www.germanamericanconference.org/partners/. There is a bar which slides back and forth when hovering on elements. In my case I can't add another element to my header and such effect should be purely CSS so instead I am using after pseudo-element.
Here, in the example: https://jsfiddle.net/1czmx08y/
As you can see there is a delay when moving between items but even if I decrease transition time, it starts twitching.
How can I avoid such behaviour? I feel like my transition is wrong.
Change all the transitions to 0.15s or 0.18s;
Isn't much better now? i think it would be better and it could be a better choice than using a plugin or more css or any js.
html {
font-family: 'Josefin Slab', 'Comfortaa', sans-serif;
font-size: 1.2em;
background: #eee;
}
ul {
position: relative;
width: 27em;
height: 2em;
margin: 100px auto;
padding: 0;
white-space: nowrap;
}
ul li {
display: inline;
text-align: center;
}
ul li a {
position: relative;
top: 0;
left: 0;
right: 25em;
bottom: 0;
display: inline-block;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: .4em .2em;
color: #09C;
text-decoration: none;
text-shadow: 0 1px 0 white;
/*transition*/
-webkit-transition: width .3s,right .3s;
-moz-transition: width .3s,right .3s;
-o-transition: width .3s,right .3s;
transition: width .19s,right .19s;
}
ul li:nth-child(1) a { width: 2em; }
ul li:nth-child(2) a { width: 4em; }
ul li:nth-child(3) a { width: 4em; }
ul li:nth-child(4) a { width: 12em; }
ul li:nth-child(5) a { width: 5em; }
ul li:last-child a::after {
content: "";
position: absolute;
right: inherit;
bottom: -3px;
width: inherit;
height: 3px;
background: #ccc;
pointer-events: none;
/*transition*/
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
-o-transition: all .5s ease;
transition: all .19s ease;
}
ul li:nth-child(1) ~ li:last-child a {
right: 25em;
width: 2em;
}
ul li:nth-child(2):hover ~ li:last-child a {
right: 21em;
width: 4em;
}
ul li:nth-child(3):hover ~ li:last-child a {
right: 17em;
width: 4em;
}
ul li:nth-child(4):hover ~ li:last-child a {
right: 5em;
width: 12em;
}
ul li:nth-child(5):last-child:hover a {
right: 0;
width: 5em;
}
ul li:hover ~ li:last-child a::after,
ul li:last-child:hover a::after { background: #c351fa; }
ul li:last-child a {
min-width: 5em;
max-width: 5em;
}
ul li a:hover,
ul li a:focus {
color: #c351fa;
background-color: rgba(255,255,255,.6);
/*transition*/
-webkit-transition: width .3s,right .3s,background-color .3s;
-moz-transition: width .3s,right .3s,background-color .3s;
-o-transition: width .3s,right .3s,background-color .3s;
transition: width .19s,right .19s,background-color .19s;
}
ul li a:focus { border-bottom: 3px solid #c351fa; }
<ul>
<li> ✿ </li><!--
--><li> Lorem </li><!--
--><li> Ipsum </li><!--
--><li> Consectetur adipisicing </li><!--
--><li> Sit amet </li>
</ul>
Related
I thought it would have been simple, I'm trying to make a small navigation with numbers which show a name below on hover which should be like this :
But I don't know how to keep it centered and without having big margins between numbers. Here is a JSFiddle
.dropdown {
font-size: 10pt;
width: 10px;
}
nav ul {
font-size: 0;
list-style: none;
margin: 0;
padding: 0;
text-align: center;
width: 100%;
}
nav li {
display: inline-block;
margin: 0;
padding: 0;
position: relative;
width: auto;
}
nav a {
color: #444;
display: block;
padding: 0 25px;
text-align: center;
text-decoration: none;
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}
nav li ul {
font-size: 10pt;
height: 20px;
left: 0;
opacity: 0;
position: absolute;
top: 35px;
visibility: hidden;
z-index: 1;
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}
nav li:hover ul {
opacity: 1;
top: 50px;
visibility: visible;
}
nav li ul li {
width: 100%;
}
nav li ul a {
background: #bbb;
}
Here the result thanks to #Ovakuro : JSFiddle
Here is a solution to your layout using flexbox. I've simplified your CSS quite a bit, let me know if you have any questions.
nav .cf,
.dropdown {
list-style: none;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
}
nav .cf li {
position: relative;
}
nav .cf li a {
color: #444;
padding: 0 10px;
text-decoration: none;
}
nav .cf li:hover .dropdown {
opacity: 1;
visibility: visible;
}
/* style your dropdown menu here */
.dropdown {
width: 100%;
list-style: none;
font-size: 10pt;
position: absolute;
top: 30px;
opacity: 0;
visibility: hidden;
z-index: 1;
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}
.dropdown li {
display: flex;
}
nav .cf .dropdown li a {
padding: 10px 20px;
background: #bbb;
text-align: center;
white-space: nowrap;
}
/* triangle */
.dropdown:after {
bottom: 100%;
content: " ";
position: absolute;
border: solid transparent;
border-bottom-color: #bbb;
border-width: 10px;
}
<nav>
<ul class="cf">
<li>
01
<ul class="dropdown">
<li>E-CAMPUS</li>
</ul>
</li>
<li>
02
<ul class="dropdown">
<li>PEGASEZBUZZ</li>
</ul>
</li>
</ul>
</nav>
To my knowledge, the only way to do this is to set a width to the ul children so you can center it after. It's necessary if you need to go beyond parents' width.
I use transform translate, but if you need to be fully backward compatible, you would do this in js. Also, you may have problems with screen sides this way, again, js is your friend.
Note : I added /* new */ in css so you can see what I did. ;) Cheers
.dropdown {
font-size: 10pt;
width: 10px;
}
nav ul {
font-size: 0;
list-style: none;
margin: 0;
padding: 0;
text-align: center;
width: 100%;
position: relative; /* new */
}
nav li {
display: inline-block;
margin: 0;
padding: 0;
position: relative;
width: auto;
}
nav a {
color: #444;
display: block;
padding: 1em;
text-align: center;
text-decoration: none;
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}
nav li ul {
font-size: 10pt;
height: 20px;
left: 0;
opacity: 0;
position: absolute;
top: 35px;
visibility: hidden;
z-index: 1;
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
left: 50%; /* new */
transform: translateX(-50%); /* new */
width: 200px; /* new */
}
nav li:hover ul {
opacity: 1;
top: 50px;
visibility: visible;
}
nav li ul li {
width: 100%;
}
nav li ul a {
background: #bbb;
}
<nav>
<ul class="cf">
<li><a class="dropdown" href="#">01</a>
<ul>
<li>E-CAMPUS</li>
</ul>
</li>
<li><a class="dropdown" href="#">02</a>
<ul>
<li>PEGASEZBUZZ</li>
</ul>
</li>
</ul>
</nav>
Is this close to what you wanted?
body {
background-color: black;
}
.dropdown {
font-size: 20pt;
width: 10px;
}
nav ul {
font-size: 0;
list-style: none;
margin: 0;
padding: 0;
text-align: center;
width: 100%;
}
nav li {
display: inline-block;
margin: 0;
padding: 0;
position: relative;
width: auto;
}
nav a {
color: gray;
display: block;
padding: 0 25px;
text-align: center;
text-decoration: none;
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}
nav li ul {
font-size: 10pt;
height: 20px;
left: 0;
opacity: 0;
position: absolute;
top: 35px;
visibility: hidden;
z-index: 1;
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}
nav li:hover ul {
opacity: 1;
top: 50px;
visibility: visible;
margin-top: -10px;
}
nav li ul li {
width: 100%;
}
nav li:hover ul:before {
content: "";
position: absolute;
bottom: -10px;
border-style: solid;
border-color: #EDEDED transparent;
display: block;
top: -8px;
bottom: auto;
right: 15px;
border-width: 0 10px 10px;
}
nav li ul a {
background: #EDEDED;
width: 100px;
margin-left: -25px;
margin-bottom: 100px;
padding: 10px;
color: #0050F7;
}
.dropdown:hover {
color: white;
}
<nav>
<ul class="cf">
<li><a class="dropdown" href="#">01</a>
<ul>
<li>E-CAMPUS</li>
</ul>
</li>
<li><a class="dropdown" href="#">02</a>
<ul>
<li>PEGASEZBUZZ</li>
</ul>
</li>
</ul>
</nav>
Or if you want your hover tags always centered you may use this:
body {
margin: 0;
padding: 0;
}
.container {
background-color: black;
width: 500px;
height: 300px;
}
ul {
list-style: none;
color: #666;
font-size: 30px;
margin: 0;
padding: 0;
text-align: center;
padding-top: 20px;
position:relative;
}
ul li {
display: inline-block;
padding: 0 12px;
}
.hover {
position:absolute;
top:70px;
text-align:center;
width:100%;
left:0;
display:none;
}
.hover span {
display: inline-block;
background-color:#fff;
color:blue;
font-size:30px;
padding:12px 20px;
}
li:hover {color:#bbb;}
li:hover .hover {display:block;}
.hover:before {
content:"";
display:inline-block;
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid #fff;
padding:0;
position:absolute;
top:-5px;
}
.hv1:before {left:154px;}
.hv2:before {left:214px;}
.hv3:before {left:278px;}
.hv4:before {left:340px;}
<div class="container">
<ul>
<li>01
<div class="hover hv1"><span>This is the first 1</span></div>
</li>
<li>02
<div class="hover hv2"><span>Tag2 here</span></div>
</li>
<li>03
<div class="hover hv3 "><span>Tag3 much much longer</span></div>
</li>
<li>04
<div class="hover hv4 "><span>Tag4</span></div>
</li>
</ul>
</div>
Notice you need a text covering enough room for the arrow to show
I'm running into a problem in my website, where an horizontal scrollbar is always showing even when i add overflow-x: hidden to the body, html elements. Instead of hiding the scrollbar, another scrollbar is added vertically and now i have two vertical scrollbars!
This happened because i have a centered navigation and add to set a child div of that same navigation, to 100% of the viewport width. Checked the developer tools in chrome and that div is going some pixels to the right.
Anyway, since overflow didn't work, i tried to change the values of the calc() function to subtract those pixels but the horizontal scrollbar is still there.
Here is my code:
<div id="container">
<ul class="nav">
<li>home</li>
<li>
destinations
<div>
<div class="nav-column">
</div>
<div class="nav-column">
</div>
<div class="nav-column">
</div>
<div class="nav-column">
</div>
<div class="nav-column">
</div>
</div>
</li>
<li>about</li>
<li>contact</li>
</ul>
</div>
And the css:
body,html {
background-color: white;
border: 0;
outline: 0;
margin: 0;
padding: 0;
max-width: 100%;
overflow-x: hidden;
}
#container {
display: block;
margin: 0 auto;
text-align: center;
position: relative;
width: 100%;
}
.nav {
cursor: default;
display: inline-block;
height: 125px;
position: relative;
top: 50px;
width: auto;
-ms-flex-pack: center;
-ms-display: -ms-flexbox;
}
.nav,
.nav a,
.nav ul,
.nav li,
.nav div {
border: none;
padding: 0;
margin: 0;
outline: none;
}
.nav a {
text-decoration: none;
}
.nav li {
list-style: none;
}
.nav > li {
display: block;
float: left;
}
.nav > li > a {
display: block;
color: black;
font-family: 'Oswald', sans-serif;
font-size: 1.2em;
font-weight: 500;
text-transform: uppercase;
height: 30px;
padding: 0 20px;
position: relative;
z-index: 510;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
transition: all .3s ease;
}
.nav li:hover a {
background: black;
color: white;
}
.nav > li > div {
border: 1px solid black;
display: inline-block;
color: black;
position: absolute;
top: 30px;
left: calc(-50vw + 50%);
width: 100vw;
opacity: 0;
overflow: hidden;
visibility: hidden;
background: white;
z-index: 500;
-webkit-transition: all .3s ease .5s;
-moz-transition: all .3s ease .5s;
-o-transition: all .3s ease .5s;
-ms-transition: all .3s ease .5s;
transition: all .3s ease .5s;
}
.nav li:hover > div {
opacity: .7;
visibility: visible ;
overflow: hidden;
}
.nav .nav-column {
background-color: white;
float: left;
text-align: left;
top: -30px;
padding: 2%;
position: relative;
width: 15%;
}
.nav .nav-column h3 {
color: #d1a559;
font-family: Orator Std, IrisUPC, sans-serif;
font-weight: 900;
margin: 20px 0 10px 0;
text-decoration: underline ;
}
.nav .nav-column li {
padding-left: 0;
font-family: Palatino linotype, Rockwell;
}
.nav .nav-column li a {
background: white;
color: black;
display: block;
}
.nav .nav-column li a:hover {
background: #d1a559;
color: white;
-webkit-transition: all .1s ease;
-moz-transition: all .1s ease;
-o-transition: all .1s ease;
-ms-transition: all .1s ease;
transition: all .1s ease;
}
#media (max-width:1420px) {
.Thumbnails {
float: none;
}
}
#media (max-width: 950px) {
.nav li:hover > div {
background-color: white;
opacity: 1;
}
.nav .nav-column {
position: relative;
width: 20%;
}
.nav .nav-column li {
list-style: none;
}
}
#media (max-width: 700px) {
.nav li:hover > div {
background-color: white;
left: 0;
opacity: 1;
width: 100%;
}
.nav .nav-column {
float: none;
}
}
.colAbout {
display: block;
float: none;
}
.span_1_of_3 {
width: 70%;
}
#media (max-width: 530px) {
.nav {
display: none;
text-align: left;
height: 150px;
top: 0;
padding: 0;
margin: 0;
position: relative;
z-index: 999;
}
.nav li {
float: none;
left: 0;
}
.nav li:hover > div {
opacity: 1;
top: 113px;
}
.nav > li > a {
border-right: none;
display: block;
left: 0;
}
/*Div contendo responsive button*/
#menu {
border: 1px solid black;
color: black;
cursor: pointer;
display: block;
font-size: 1.3em;
left: 0;
margin: 5%;
position: relative;
text-align: center;
z-index: 540;
width: 1.4em;
}
#container {
left: 0;
display: block;
padding: 0;
position: relative;
width: 100%;
}
ul {
width: 100%;
list-style: none;
}
}
#media (min-width: 530px) {
#menu {
display: none;
}
}
And a fiddle example
If you just want to hide the scrollbar:
#container {
overflow: hidden!important;
}
I encountered the same issue. I still don't know the root cause, but setting overflow to "-moz-hidden-unscrollable" seems to hide the scrollbar.
.container {
overflow: -moz-hidden-unscrollable
}
I have checked your CSS. To prevent the scrollbar from being displayed, you should comment out two CSS properties: position: relative; top: 34px;
.nav {
cursor: default;
display: inline-block;
height: 125px;
width: auto;
-ms-flex-pack: center;
-ms-display: -ms-flexbox;
}
So, I have a simple NAV that I came up with, and I'm trying to add a burger icon that will only show up when the screen is small.
Currently, my burger is just the word Menu, but I'd like to have this hidden by default. However, my code is overridden by a display:inline, that is earlier in the code. even if I add !Important.
Any one have any ideas as to how I can hide the menu element?
JSFIDDLE https://jsfiddle.net/Lwwgpx9k/
My code is below.
.html
<div class="nav">
<ul>
<li class="hidden">Menu</li>
<li class="home"><a class="active" href="#">Home</a></li>
<li class="gallery">Gallery</li>
<li class="tutorials">Tutorials</li>
<li class="about">About</li>
</ul>
</div>
.css
body {
background: #333;
}
.nav ul {
color: #e6e9e9;
position: fixed;
top: 60px;
padding-left: 5%;
text-align: center;
margin: 0;
}
.nav ul li {
line-height: 35px;
float: left;
width: 120px;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 0px 10px;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
.nav ul li:hover {
background: #6A1B9A;
color: #e6e9e9;
}
.nav ul li ul {
padding: 0;
position: absolute;
top: 35px;
left: 0;
text-align: left;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-transition: opacity 0.5s;
}
.nav ul li ul li {
width: 200px;
background: #555;
display: block;
color: #e6e9e9;
}
.nav ul li ul li:hover {
background: #6A1B9A;
}
.nav ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
transition-delay: 2s;
-webkit-transition-delay: 2s;
/* Safari */
}
.nav a {
font-size: 1.4em;
text-decoration: none;
color: #e6e9e9;
display: block;
transition: .3s background-color;
}
.nav a:hover {
background-color: #6A1B9A;
color: #e6e9e9;
}
.nav a.active {
background-color: #6A1B9A;
color: #e6e9e9;
cursor: default;
}
.nav ul {
color: #e6e9e9;
position: fixed;
top: 60px;
padding-left: 5%;
text-align: center;
margin: 0;
}
.nav ul li {
line-height: 35px;
float: left;
width: 120px;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 0px 10px;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
.nav ul li:hover {
background: #6A1B9A;
color: #e6e9e9;
}
.nav ul li ul {
padding: 0;
position: absolute;
top: 35px;
left: 0;
text-align: left;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-transition: opacity 0.5s;
}
.nav ul li ul li {
width: 200px;
background: #555;
display: block;
color: #e6e9e9;
}
.nav ul li ul li:hover {
background: #6A1B9A;
}
.nav ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
transition-delay: 2s;
-webkit-transition-delay: 2s;
/* Safari */
}
.nav a {
font-size: 1.4em;
text-decoration: none;
color: #e6e9e9;
display: block;
transition: .3s background-color;
}
.nav a:hover {
background-color: #6A1B9A;
color: #e6e9e9;
}
.nav a.active {
background-color: #6A1B9A;
color: #e6e9e9;
cursor: default;
}
.hidden {
display: none; !important
}
your problem is here
hidden {
display: none; !important<---- this important should be inside ";"
}
it should be
hidden {
display: none !important;
}
I am currently working on a menu bar that expands vertically upwards. When I change the overflow to visible rather than hidden, the menu expands in the correct place, however the whole menu is visible which I do not want to happen. With overflow:hidden; the menu expands but only when you hover over the partially expanded menu above where I would like it to expand. Can anyone help?
.HomeBottomMenu {
-webkit-font-smoothing:antialiased;
text-align: center;
text-align: justify;
position: fixed;
bottom: 6em;
z-index:9999;
}
.HomeBottomMenu ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.HomeBottomMenu ul ul {
height: 0px;
}
.HomeBottomMenu ul ul:hover {
height:532px;
-webkit-transition: height 1s ease;
-moz-transition: height 1s ease;
-o-transition: height 1s ease;
-ms-transition: height 1s ease;
transition: height 1s ease;
}
.HomeBottomMenu ul li{
position: relative;
line-height: 21px;
min-width: 220px;
text-align: center;/* Used to be left*/
background: #424242;
}
.HomeBottomMenu ul li a{
display: block;
padding: 8px 8px;
color: #fff;
text-decoration:none;
text-align: left;
font-family: 'BebasNeueRegular', Arial, sans-serif;
font-size: 18px;
font-weight: bold;
}
.HomeBottomMenu ul li a:hover{
color: #fff;
background: #25a0da;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
.HomeBottomMenu ul li .dropdown{
background: #f2f2f2;
display: hidden;
position: absolute;
left: -0.01em;
overflow: hidden;
}
.HomeBottomMenu ul li:hover .dropdown{
/* Display the initial dropdown */
display: block;
bottom: 100%;
position: absolute;
background: #939393;
min-height: 50px;
}
.HomeBottomMenu ul li ul.dropdowndropdown {
position: relative;
height:100%;
display:inline-block;
bottom:100%;
}
.HomeBottomMenu ul li ul :hover .dropdowndropdown{
position: relative;
display:inline-block;
}
.HomeBottomMenu ul li ul.dropdowndropdown li{
display: inline-block;
/*Colour of level 1, level 2...*/
background-color: rgba(0, 90, 235, 0.33);
bottom: 100%;
}
.HomeBottomMenu ul li ul.dropdowndropdown li:hover{
position: relative;
}
.HomeBottomMenu ul li ul.dropdowndropdown li a{
color:#fff;
font-size:16px;
padding: 10px 10px;
text-align:center;
}
.HomeBottomMenu ul li ul .dropdowndropdown li a :hover{
color: #fff;
}
Changed the following and it works now:
.HomeBottomMenu ul li .dropdown{
background: #f2f2f2;
position: absolute;
left: -0.01em;
overflow:hidden;
display: none;
}
.HomeBottomMenu ul li:hover .dropdown{
display: block;
bottom: 0%;
position: absolute;
background: #939393;
min-height: 50px;
}
The padding around the link for my dropdown menu isn't clickable. When I mouse over the actual text, it changes color and becomes clickable. How can I make the padding clickable? I read that I should style it as an inline-block, but that didn't work. This is also my first post, so correct me for the countless things that I probably did wrong.
CSS:
body {
font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
padding: 20px 50px 150px;
font-size: 13px;
text-align: left;
background-position:center;
background-image:url(sun.jpg);
}
a {
display:inline-block;
color: #6FF;
text-decoration: none;
}
a:hover {
color: #FFF;
}
ul {
color:#6FF
text-align: left;
display: inline-block;
margin: 0;
padding: 1px 1px 1px 0;
list-style: none;
}
ul li {
color: purple;
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -10px;
position: relative;
padding: 20px 20px;
background: #fff;
cursor: pointer;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-ms-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
ul li:hover {
background: #555;
color: #fff;
}
ul li ul {
padding:0;
position:absolute;
top: 54px;
left: 0;
width: 150px;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-transition: opacity 0.5s;
}
ul li ul li {
background-color:#555;
color:#6FF;
display: block;
}
ul li ul li:hover { background: #555; }
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
You should put the padding to the link, no the list item because the link is what is clickable.
body {
font-family:'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
padding: 20px 50px 150px;
font-size: 13px;
text-align: left;
background-position:center;
background-image:url(sun.jpg);
}
a {
padding: 20px 20px;
display:inline-block;
color: #6FF;
text-decoration: none;
}
a:hover {
color: #FFF;
}
ul {
color:#6FF text-align: left;
display: inline-block;
margin: 0;
padding: 1px 1px 1px 0;
list-style: none;
}
ul li {
color: purple;
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -10px;
position: relative;
background: #fff;
cursor: pointer;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-ms-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
ul li:hover {
background: #555;
color: #fff;
}
ul li ul {
padding:0;
position:absolute;
top: 54px;
left: 0;
width: 150px;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-transition: opacity 0.5s;
}
ul li ul li {
background-color:#555;
color:#6FF;
display: block;
}
ul li ul li:hover {
background: #555;
}
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
<ul>
<li>First link
</li>
<li>First link
</li>
<li>First link
</li>
<li>First link
</li>
<li>First link
</li>
<li>First link
</li>
</ul>