Adding css drop down menu in a template - css

I downloaded a template for my company. I managed to get most things done, but I want to make a drop down menu and I just can't handle it. I tried this explanation How to add drop down menu using CSS? because I don't know JavaScript or jQuery, but it doesn't seem to work on this particular template. Am I describing the wrong class in css?
HTML
</nav>
</section>
<header class="sixteen columns alpha omega">
<nav class="main-nav sixteen columns">
<ul class="ten columns alpha">
<li>Start</li>
<li>O Kancelarii</li>
<li>Zakres Usług</li>
<ul>
<li>Something You do</li>
<li>TODO</li>
</ul>
<li>Press Room</li>
<li>Kontakt</li>
</ul>
<div class="social six columns omega">
</div> <!--Close Social Div-->
</nav>
CSS
.main-nav {
margin-top: 10px;
padding-top: 3px;
padding-bottom: 3px;
border-top: 1px solid #e3e3e3;
border-bottom: 1px solid #e3e3e3;
}
.main-nav li {
display: inline;
margin-right: 15px;
}
.social a:link {
float: right;
background-image: url(../img/facebook.png);
width: 30px;
height: 30px;
background-position: 0 -30px;
-webkit-transition: background-position .3s ease;
-moz-transition: background-position .3s ease;
-o-transition: background-position .3s ease;
transition: background-position .3s ease;
margin-left: 2px;
}
.social a:last-child {
float: right;
background-image: url(../img/twitter.png);
width: 30px;
height: 30px;
background-position: 0 -30px;
-webkit-transition: background-position .3s ease;
-moz-transition: background-position .3s ease;
-o-transition: background-position .3s ease;
transition: background-position .3s ease;
}
.social a:hover {
background-position: 0 0;
}
.main-nav li {
position: relative;
}
.main-nav ul ul{
position:absolute;
left: 0;
top: 100px; /* height of the parent list item */
display: none; /* hide it */
}
.main-nav li:hover > ul{ /* show it when mouse is over the parent list item */
display:block;
}
Here is the whole css http://jsfiddle.net/9LcfX/18/
I've tried to rename the description in css from main_nav to alpha etc. but nothing.
Please help me, in advance thanks for Your time.

some structure problem in ur html code just replace html code with below code
<nav class="main-nav sixteen columns">
<ul class="ten columns alpha">
<li>Start</li>
<li>O Kancelarii</li>
<li>Zakres Usług
<ul>
<li>Something You do </li>
<li>TODO </li>
</ul>
</li>
<li>Press Room</li>
<li>Kontakt</li>
</ul>
<div class="social six columns omega"> </div>
</nav>

Related

How to center Bootstrap navigation bar

How can I get this navigation bar to center?
The class menu I suppose is built in with bootstrap.min.css.
#header {
position: fixed;
width: 100%;
z-index: 999;
}
#header .header-content {
margin: 0px auto;
max-width: 1170px;
padding: 60px 0;
width: 100%;
-moz-transition: padding 0.4s;
-o-transition: padding 0.4s;
-webkit-transition: padding 0.4s;
transition: padding 0.4s;
}
.navigation {
float: right;
}
.navigation li {
display: inline-block;
}
.navigation a {
color: white;
font-size: 15px;
font-weight: bold; /* Normal - Bold - 400 */
margin-left: 30px;
letter-spacing: 4px;
text-transform: uppercase;
}
.navigation a:hover, .navigation a.active {
color: white;
}
<header id="header">
<div class="menu">
<div class="header-content clearfix">
<nav class="navigation" role="navigation">
<ul>
<li><a data-scroll href="#sec1">Inicio</a></li>
<li><a data-scroll href="#sec2">UEFA</a></li>
<li><a data-scroll href="#sec4">Equipo</a></li>
<li><a data-scroll href="#sec3">Contacto</a></li>
</ul>
</nav>
Menu<span></span>
</div>
</div>
</header>
If you remove the float: right from .navigation and you set text-align: center to that div you can center it.
https://codepen.io/anon/pen/BmBPej

Before and After Hover Effect

I have been scouring the web on before and after effects and I just haven't.. found anything remotely helpful. It's like the gray area of CSS. I was wondering how I would go about doing an effect like on twitter's homepage: This is on the hover effect. http://imgur.com/a/jBikq. It has a transition too, but I'm not sure how to implement it. Again i'm not even sure if this is using before and after, I imagine it is hover, but any help would be really appreciated.
Here is my code for my navigation:
<div id="navbar3" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
</div>
You can do it with :after and :before pseudo selector.
Im created an example based on your image, its look like this:
#import url('https://fonts.googleapis.com/css?family=Roboto');
body{
padding: 5%;
}
.exemple {
font-family: 'Roboto', sans-serif;
position: relative;
padding: 2.5% 3.5%;
text-decoration: none;
font-size: 0.9em;
color: #333333;
transition: ease .1s;
-webkit-transition: ease .1s;
}
.exemple:before {
font-family: 'FontAwesome';
content: '\f0e7';
font-size: 1.1em;
margin-right: 10px;
}
.exemple:after {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 0px;
background: #20abe1;
transition: ease .1s;
-webkit-transition: ease .1s;
}
.exemple:hover {
color: #20abe1;
}
.exemple:hover:after{
height: 4px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
Moments
Working Fiddle
You can definitely use a ::before or you can animate the border/padding and it will create the same grow effect. Working fiddle here: FIDDLE
You haven't provided a much detail on the exact thing you're attempting to replicate. I'm going to assume it's the underline that animates up from the bottom of a navigation item.
To do this you will need to use CSS transition.
A simplified version of what Twitter is doing is below. They set a height on the <a> and <li> and add a border to the <a>. Since they have overflow:hidden; applied to the border of the <li> the border they applied to the <a> is initially hidden.
When the <li> is hovered the height of the <a> is reduced. They use transition on the height to animate the border up into view.
ul,
li {
margin: 0;
padding: 0;
list-style: none;
}
li {
float: left;
height: 40px;
overflow: hidden;
}
a {
display: block;
height: 40px;
padding: 0 10px;
line-height: 40px;
text-decoration: none;
overflow: hidden;
border-bottom: 3px solid #0c0;
transition: height 250ms ease-in-out;
}
li:hover a {
height: 37px;
}
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
Here is another way of animating in the underline with pseudo elements.
ul,
li {
margin: 0;
padding: 0;
list-style: none;
}
li {
position: relative;
float: left;
}
a {
display: block;
padding: 0 10px;
line-height: 40px;
text-decoration: none;
}
a:after {
content: '';
position: absolute;
bottom: 0;
left: 0;
display: block;
height: 0;
width: 100%;
text-align: center;
background-color: #0c0;
transition: height 250ms ease-in-out;
}
li:hover a:after {
height: 3px;
}
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>

CSS Menubar no SubMenus

I am a beginner in CSS and I would like to create a Menu with SubItems.
I have found a model on the internet and I would like to customize it but it doesn't work.
In the text you can find the XHTML and CSS File with just the Menu.
The Menu is shown correct but I want that the subMenus like 'Team' is shown with the corresponding Item.
I have searched on the internet and customized the " #menu ul li:hover > ul { " several times but I can't see the error. I think the error must be in that function because I want to appear the menu when I move the mouse over the Menu.
Could you please tell me where the error is?
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300,700);
p, ul, li, div, nav
{
padding:0; margin:0;
}
body {
font-family:Calibri;
}
#menu
{
position: absolute; overflow: auto; z-index:2;
}
.parent-menu {
background-color: white;
color:black;
min-width:200px;
float:left;
}
#menu ul
{
list-style-type:none;
}
#menu ul li a {
padding:10px 15px;
display:block;
color:black;
text-decoration:none; }
#menu ul li a:hover {
background-color:blue;
}
#menu ul li:hover > ul {
left: 200px; -webkit-transition: left 200ms ease-in; -moz-transition: left 200ms ease-in; -ms-transition: left 200ms ease-in; transition: left 200ms ease-in;
}
#menu ul li > ul {
position: absolute; background-color: #333; top: 0; left: -200px; min-width: 200px; z-index: -1; height: 100%; -webkit-transition: left 200ms ease-in; -moz-transition: left 200ms ease-in; -ms-transition: left 200ms ease-in; transition: left 200ms ease-in; }
#menu ul li > ul li a:hover {
background-color:#2e2e2e;
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width"/>
<title>CSS Site</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<header class="header">
<h1>CSS Site</h1>
</header>
<nav id="menu">
<ul class="parent-menu">
<li>Home</li>
<li>
About
<ul>
<li> Team</li>
<li> Philosophie</li>
<li> Partner</li>
</ul>
</li>
<li>References</li>
<li>
Contact
<ul>
<li>Way</li>
<li>Rooms</li>
</ul>
</li>
</ul>
</nav>
</body>
</html>
You have your ul being child of li if you want it to stay like this you would need to do next manipulations.
http://plnkr.co/edit/JaVAaMunLFnT3TPGNQnY?p=preview
/* Styles go here */
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300,700);
p, ul, li, div, nav
{
padding:0; margin:0;
}
body {
font-family:Calibri;
}
#menu
{
position: absolute; overflow: auto; z-index:2;
}
.parent-menu {
background-color: white;
color:black;
min-width:400px;
float:left;
}
#menu ul
{
list-style-type:none;
}
#menu li {
width:200px;
}
#menu ul li a {
padding:10px 15px;
display:block;
color:black;
text-decoration:none; }
#menu ul li a:hover {
background-color:blue;
}
#menu ul li:hover > ul {
top: 0px;
-webkit-transition: top 200ms ease-in;
-moz-transition: top 200ms ease-in;
-ms-transition: top 200ms ease-in;
transition: top 200ms ease-in;
}
#menu ul li > ul {
position: absolute;
background-color: #333;
top: -200px;
left: 200px;
min-width: 200px;
z-index: 0;
height: 100%;
-webkit-transition: left 200ms ease-in;
-moz-transition: left 200ms ease-in;
-ms-transition: left 200ms ease-in;
transition: left 200ms ease-in;
}
#menu ul li > ul li a:hover {
background-color:#2e2e2e;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<header class="header">
<h1>CSS Site</h1>
</header>
<nav id="menu">
<ul class="parent-menu">
<li>Home</li>
<li>
About
<ul>
<li> Team</li>
<li> Philosophie</li>
<li> Partner</li>
</ul>
</li>
<li>References</li>
<li>
Contact
<ul>
<li>Way</li>
<li>Rooms</li>
</ul>
</li>
</ul>
</nav>
</body>
</html>
I changed animation from left to top, because it was causing problems with z-indexes, if it's necessary to be left, let me know and I'll try to help you out
You were missing too many things.
your HTML
<header class="header">
<h1>CSS Site</h1>
</header>
<nav id="menu">
<ul class="parent-menu">
<li>Home</li>
<li>
About
<ul>
<li> Team</li>
<li> Philosophie</li>
<li> Partner</li>
</ul>
</li>
<li>References</li>
<li>
Contact
<ul>
<li>Way</li>
<li>Rooms</li>
</ul>
</li>
</ul>
</nav>
CSS code that I've created
ul {
list-style: none;
}
li {
background-color: #fff;
cursor: pointer;
padding: 10px 15px;
max-width: 300px;
}
a {
color: black;
text-decoration: none;
}
.parent-menu li:hover a,
.parent-menu li ul li:hover {
color: blue;
}
.parent-menu li ul {
display: none;
}
.parent-menu li:hover ul {
display: block;
position: absolute;
left: 290px;
top: 0px;
}
.parent-menu li {
position: relative;
}
In it I've created a basic code which is you required to do so.
Try to understand code yourself and if you stuck somewhere then post your comment here.

How to combine first-child:hover and another element have :before? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I want to make effect on :before element when the mouse hover on first-child of the list item so the code would be
li:first-child:hover ul:before { Code here }
To make it more clearly see the code from here or see below
( i want to make the effect on .sub1-ul:before )
* {
box-sizing: border-box;
text-decoration: none;
list-style-type: none
}
nav.nav-menu {
width:100%;
margin: 0 auto;
z-index: 2000;
}
ul.menu-wrapper {
position: relative;
width: 770px;
height: 90px;
padding-left: 100px;
padding-top: 15px;
margin: 0px auto;
z-index: 2000;
}
li.nav-item {
position: relative;
float: left;
margin-left: 30px
}
li.nav-item > a {
display: inline-block;
width: 150px;
height: 50px;
padding-top: 11px;
background-color: #3498DB;
color: #fff;
text-align: center;
font-weight: 600;
font-size: 19px;
border: 1px solid #5aabe1;
-webkit-transition: background-color 400ms, color 700ms ease-out;
-moz-transition: background-color 400ms, color 700ms ease-out;
transition: background-color 400ms, color 700ms ease-out
}
li.nav-item:hover > a {
background-color: #fffffc;
color: #3498db
}
/* ========== START SUB1 ========== */
.sub1-ul:before {
content: "";
display: inline-block;
position: relative;
width: 0px;
top: 15px;
left: 30px;
border-width: 0px 15px 15px 0px;
border-color: #0f0 #0F8FD3 transparent #000;
border-style: solid solid solid solid;
transform: rotate(-45deg)
}
.sub1-ul li:first-child:hover .sub1-ul:before {
content: "";
display: inline-block;
position: relative;
width: 0px;
top: 15px;
left: 3px;
border-width: 0px 15px 15px 0px;
border-color: #0f0 #000 transparent #000;
border-style: solid solid solid solid;
transform: rotate(-45deg)
}
.sub1-ul {
position: absolute;
top: 50px;
width: 100%;
height: 0;
margin-top:-10px ;
visibility: hidden;
overflow: hidden;
opacity: 0;
z-index: 9999;
-webkit-transition: all .2s linear;
-moz-transition: all .2s linear;
transition: all .2s linear
}
li.nav-item:hover .sub1-ul {
height: auto;
visibility: visible;
overflow: visible;
opacity: 1
}
.sub1-item {
position: relative;
top: -1px;
left: -36%;
width: 150px;
margin-top: 3px;
-webkit-transition:margin-left 200ms linear;
-moz-transition:margin-left 200ms linear;
transition:margin-left 200ms linear
}
.sub1-item:hover {
margin-left: 4px;
}
.sub1-item .sub1-a {
display: inline-block;
width: 150px;
height: 50px;
padding-top: 15px;
background-color: #0F8FD3;
text-align: center;
color: #fff;
font-size: 17px;
border-left: 6px solid #4C4C4C;
-webkit-transition: background-color 400ms,
border-left-color 400ms,
padding-left 200ms linear;
-moz-transition: background-color 400ms,
border-left-color 400ms,
padding-left 200ms linear;
transition: background-color 400ms,
border-left-color 400ms,
padding-left 500ms linear
}
.sub1-item:hover .sub1-a {
padding-left: 6px;
border-left-color: #e67e22;
}
/* ========== START SUB2 ========== */
.sub2-ul {
position: absolute;
top: 0px;
left: 100%;
width: 150px;
padding: 0;
margin: 0;
visibility: hidden;
overflow: hidden;
opacity: 0;
-webkit-transition: all 400ms ease;
-moz-transition: all 400ms ease;
transition: all 400ms ease
}
.sub1-item:hover .sub2-ul {
height: auto;
visibility: visible;
overflow: visible;
opacity: 1
}
.sub2-item {
position: relative;
margin-bottom:2px;
}
.sub2-item:hover {
border-left-color: #4c4c4c
}
.sub2-item .sub2-a {
display: inline-block;
width:150px;
height:50px;
margin-left: 1px;
padding-top:15px;
background-color: #3498DB;
color: #fff;
text-align: center;
font-size: 17px;
font-weight: normal;
border-left: 5px solid #e67e22;
-webkit-transition:all 200ms ease-in-out;
-moz-transition:all 200ms ease-in-out;
transition: all 200ms ease-in
}
.sub2-item:hover .sub2-a {
border-left-color: #4c4c4c
}
<nav id="sec-nav" class="nav-menu">
<ul class="menu-wrapper">
<li class="nav-item"> Menu1
<ul class="sub1-ul">
<!-- ===== Want to move before with this list item when mouseover on it =====-->
<li class="sub1-item">
<a class="sub1-a" href="#"> sub menu </a>
<ul class="sub2-ul">
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
</ul>
</li>
<!--================ Ens of the list item ======================== -->
<li class="sub1-item">
<a class="sub1-a" href="#"> sub menu </a>
<ul class="sub2-ul">
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
</ul>
</li>
<li class="sub1-item"><a class="sub1-a" href="#"> sub menu </a>
</li>
<li class="sub1-item"><a class="sub1-a" href="#"> sub menu </a>
</li>
<li class="sub1-item"><a class="sub1-a" href="#"> sub menu </a>
</li>
</ul>
</li>
<li class="nav-item"> Menu2
</li>
<li class="nav-item"> Menu3
</li>
</ul>
</nav>
You need to adjust the CSS selector to be .sub1-ul > li:first-child:before because you want the pseudo-element to be on the first-child so that it moves with the secondary menu.
You then have to adjust
.sub1-ul > li:first-child .sub2-ul {
top: 20px;
}
so that the top has the right number of pixels to keep it lined up with the top edge of the the first sub-menu.
Slightly hard to explain, but it works.
* {
box-sizing: border-box;
text-decoration: none;
list-style-type: none
}
nav.nav-menu {
width: 100%;
margin: 0 auto;
z-index: 2000;
}
ul.menu-wrapper {
position: relative;
width: 770px;
height: 90px;
padding-left: 100px;
padding-top: 15px;
margin: 0px auto;
z-index: 2000;
}
li.nav-item {
position: relative;
float: left;
margin-left: 30px
}
li.nav-item > a {
display: inline-block;
width: 150px;
height: 50px;
padding-top: 11px;
background-color: #3498DB;
color: #fff;
text-align: center;
font-weight: 600;
font-size: 19px;
border: 1px solid #5aabe1;
-webkit-transition: background-color 400ms, color 700ms ease-out;
-moz-transition: background-color 400ms, color 700ms ease-out;
transition: background-color 400ms, color 700ms ease-out
}
li.nav-item:hover > a {
background-color: #fffffc;
color: #3498db
}
/* ========== START SUB1 ========== */
.sub1-ul > li:first-child:before {
content: "";
display: inline-block;
position: relative;
width: 0px;
top: 15px;
left: 65px;
border-width: 0px 15px 15px 0px;
border-color: #0f0 #0F8FD3 transparent #000;
border-style: solid solid solid solid;
transform: rotate(-45deg);
transition: left 200ms linear
}
.sub1-ul {
position: absolute;
top: 50px;
width: 100%;
height: 0;
margin-top: -10px;
visibility: hidden;
overflow: hidden;
opacity: 0;
z-index: 9999;
-webkit-transition: all .2s linear;
-moz-transition: all .2s linear;
transition: all .2s linear;
border: 1px dotted blue;
}
li.nav-item:hover .sub1-ul {
height: auto;
visibility: visible;
overflow: visible;
opacity: 1
}
.sub1-item {
position: relative;
top: -1px;
left: -36%;
width: 150px;
margin-top: 3px;
-webkit-transition: margin-left 200ms linear;
-moz-transition: margin-left 200ms linear;
transition: margin-left 200ms linear
}
.sub1-item:hover {
margin-left: 4px;
}
.sub1-item .sub1-a {
display: inline-block;
width: 150px;
height: 50px;
padding-top: 15px;
background-color: #0F8FD3;
text-align: center;
color: #fff;
font-size: 17px;
border-left: 6px solid #4C4C4C;
-webkit-transition: background-color 400ms, border-left-color 400ms, padding-left 200ms linear;
-moz-transition: background-color 400ms, border-left-color 400ms, padding-left 200ms linear;
transition: background-color 400ms, border-left-color 400ms, padding-left 500ms linear
}
.sub1-item:hover .sub1-a {
padding-left: 6px;
border-left-color: #e67e22;
}
/* ========== START SUB2 ========== */
.sub2-ul {
position: absolute;
top: 0px;
left: 100%;
width: 150px;
padding: 0;
margin: 0;
visibility: hidden;
overflow: hidden;
opacity: 0;
-webkit-transition: all 400ms ease;
-moz-transition: all 400ms ease;
transition: all 400ms ease
}
.sub1-ul > li:first-child .sub2-ul {
top: 20px;
}
.sub1-item:hover .sub2-ul {
height: auto;
visibility: visible;
overflow: visible;
opacity: 1
}
.sub2-item {
position: relative;
margin-bottom: 2px;
}
.sub2-item:hover {
border-left-color: #4c4c4c
}
.sub2-item .sub2-a {
display: inline-block;
width: 150px;
height: 50px;
margin-left: 1px;
padding-top: 15px;
background-color: #3498DB;
color: #fff;
text-align: center;
font-size: 17px;
font-weight: normal;
border-left: 5px solid #e67e22;
-webkit-transition: all 200ms ease-in-out;
-moz-transition: all 200ms ease-in-out;
transition: all 200ms ease-in
}
.sub2-item:hover .sub2-a {
border-left-color: #4c4c4c
}
<nav id="sec-nav" class="nav-menu">
<ul class="menu-wrapper">
<li class="nav-item"> Menu1
<ul class="sub1-ul">
<li class="sub1-item">
<a class="sub1-a" href="#"> sub menu </a>
<ul class="sub2-ul">
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
</ul>
</li>
<li class="sub1-item">
<a class="sub1-a" href="#"> sub menu </a>
<ul class="sub2-ul">
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
<li class="sub2-item"><a class="sub2-a" href="#"> sub menu2 </a>
</li>
</ul>
</li>
<li class="sub1-item"><a class="sub1-a" href="#"> sub menu </a>
</li>
<li class="sub1-item"><a class="sub1-a" href="#"> sub menu </a>
</li>
<li class="sub1-item"><a class="sub1-a" href="#"> sub menu </a>
</li>
</ul>
</li>
<li class="nav-item"> Menu2
</li>
<li class="nav-item"> Menu3
</li>
</ul>
</nav>

How to add a transition to a absolute positioned box on hover

Hi I have created boxes with overflow: hidden, now on hover I would like for the box to drop down showing inner box.
I have created this and it works fine however I would like to use a transition on this effect to smoothen the drop down. I have added the transition and it is not working.
Any advice would be great on this thank you.
<html>
<head>
<title></title>
<style type="text/css">
#items {width:300px;}
.item {width:100px;border:solid 1px #ccc;float:left;height:20px;
z-index:0;overflow:hidden;position:relative;}
.item:hover{overflow:visible;z-index:100;}
.item:hover .inner{z-index: 100;}
.inner{position: absolute;
background: white;
width: 100%;
}
</style>
</head>
<body>
<div id="items">
<div class="item"><div class="inner">text 1<br>text 1<br>text 1</div></div>
<div class="item"><div class="inner">text 2<br>text 2<br>text 2</div></div>
<div class="item"><div class="inner">text 3<br>text 3<br>text 3</div></div>
<div class="item"><div class="inner">text 4<br>text 4<br>text 4</div></div>
<div class="item"><div class="inner">text 5<br>text 5<br>text 5</div></div>
<div class="item"><div class="inner">text 6<br>text 6<br>text 6</div></div>
<div class="item"><div class="inner">text 7<br>text 7<br>text 7</div></div>
<div class="item"><div class="inner">text 8<br>text 8<br>text 8</div></div>
<div class="item"><div class="inner">text 9<br>text 9<br>text 9</div></div>
<div class="item"><div class="inner">text 10<br>text 10<br>text 10</div></div>
</div>
</body>
</html>
You can build the menu you want with just CSS, but you'll need a better html structure. I don't want to rebuild the wheel, so I got one (a very simple one) that is already done:
http://cssdeck.com/labs/pure-css3-smooth-drop-down-menu
HTML
<nav>
<ul class="cf">
<li>Menu Item 1</li>
<li><a class="dropdown" href="#">Menu Item 2</a>
<ul>
<li>Sub-menu Item 1</li>
<li>Sub-menu Item 2</li>
<li>Sub-menu Item 3</li>
</ul>
</li>
<li>Menu Item 3</li>
<li>Menu Item 4</li>
</ul>
</nav>
CSS
nav ul {
-webkit-font-smoothing:antialiased;
text-shadow:0 1px 0 #FFF;
background: #ddd;
list-style: none;
margin: 0;
padding: 0;
width: 100%;
}
nav li {
float: left;
margin: 0;
padding: 0;
position: relative;
min-width: 25%;
}
nav a {
background: #ddd;
color: #444;
display: block;
font: bold 16px/50px sans-serif;
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 .dropdown:after {
content: ' ▶';
}
nav .dropdown:hover:after{
content:'\25bc'
}
nav li:hover a {
background: #ccc;
}
nav li ul {
float: left;
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 {
float: none;
width: 100%;
}
nav li ul a:hover {
background: #bbb;
}
/* Clearfix */
.cf:after, .cf:before {
content:"";
display:table;
}
.cf:after {
clear:both;
}
.cf {
zoom:1;
}​
Try using jQuery Animations to that:
Your div for id=items should be.
<div id=items onmouseover=effects() onmouseout=normal()>
</div>
And your javascript should be:
<script>
function effects()
{
$(".inner").show();
}
function normal()
{
$(".inner").hide();
}
</script>

Resources