I have a task to create a drop-down menu and i create it with using absolute and negative value but i can change my mind i want to create a drop-down without using absolute there is any possibility to create and how can do it kindly help in this query
.mainmenu {
position: relative;
cursor: pointer;
display: inline-block;
padding: 15px;
-webkit-transition: all .5s;
}
.submenu {
position: absolute;
height: 0px;
opacity: 0;
-webkit-transition: all .5s;
}
.mainmenu:hover {
border: 1px solid #000;
-webkit-transition: all .5s;
}
.mainmenu:hover .submenu {
border: 1px solid #000;
padding: 50px;
height: auto;
top: 100%;
left: -1px;
opacity: 1;
-webkit-transition: all .5s;
}
.mainmenu:hover .hide_line {
height: 5px;
width: 100%;
position: absolute;
top: 100%;
right: 0px;
background: #fff;
z-index: 1000;
}
<div class="mainmenu">
Menu
<div class="hide_line">
</div>
<div class="submenu">
submenu
</div>
</div>
You can use list for this purpose
.mainmenu a{
text-decoration:none;
color:#000000;
}
.mainmenu {
position: relative;
cursor: pointer;
display: inline-block;
padding: 15px;
-webkit-transition: all .5s;
list-style:none;
}
.mainmenu > li{
padding-left:0px;
margin-left:0px;
}
.submenu {
opacity:0;
list-style:none;
}
.mainmenu:hover .submenu {
border: 1px solid #000;
height: auto;
opacity: 1;
-webkit-transition: all .5s;
}
.submenu li{
padding-left:0px;
margin-left:0px;
}
<ul class="mainmenu">
<li><a href='#'>Main Menu</a>
<ul class="submenu">
<li><a href='#'>Sub menu</a></li>
</ul>
</li>
</ul>
I hope you can do rest of the formatting
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I am trying add notification icon, but is overflow text and dont on left.
Here is my code (run the snippet to see the result):
.dropdown {
display: inline-block;
cursor: pointer;
border: 1px solid #fff;
}
.dropdown:hover {
color: #e1a900;
}
.dropdown-content {
background-color: #333333;
display: none;
position: relative;
min-width: 180px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
margin-top: 64px;
}
.dropdown-content a {
color: #fff;
font-weight: bold;
padding: 12px 12px;
text-decoration: none;
display: block;
-o-transition:color .2s ease-out, background .3s ease-in;
-ms-transition:color .2s ease-out, background .3s ease-in;
-moz-transition:color .2s ease-out, background .3s ease-in;
-webkit-transition:color .2s ease-out, background .3s ease-in;
transition:color .2s ease-out, background .3s ease-in;
}
.dropdown-content a:hover {background-color: #cc9900;}
.dropdown:hover .dropdown-content {display: block;}
.bellimg {
padding-top: 5px;
}
.bellnumbers {
font-size:12px;
background-color:red;
width:16px;
line-height: 16px;
text-align: center;
color:#fff;
z-index: 2;
border-radius: 3px;
position: absolute;
left: 30px;
}
.bell {
border: 1px solid #fff;
width: 48px;
height: 42px;
left: 30;
position: absolute;
}
.notificationicon {
position: absolute;
top: 0px;
right: 0px;
border: 1px solid #fff;
}
/********************************
* Menu Styles *
*********************************/
#menu {
height: 64px;
width: 450px;
}
#menu ul,#menu li {
margin: 0;
padding: 0;
list-style: none;
}
#menu li {
float: left;
display: inline;
position: relative;
}
#menu li a {
color: #fff;
font-weight: bold;
-o-transition: color .2s ease-out, background .3s ease-in;
-ms-transition: color .2s ease-out, background .3s ease-in;
-moz-transition: color .2s ease-out, background .3s ease-in;
-webkit-transition: color .2s ease-out, background .3s ease-in;
transition: color .2s ease-out, background .3s ease-in;
}
#menu a {
display: block;
line-height: 35px;
padding: 14px 10px 14px 5px;
text-decoration: none;
color: #fff;
border-bottom: 1px solid #000;
}
#menu li:hover > a,#menu li a:hover {
color: #fff;
background-color: #e1a900;
}
#menu input {
display: none;
margin: 0 0;
padding: 0 0;
width: 80px;
height: 35px;
opacity: 0;
cursor: pointer;
}
#menu label {
display: none;
width: 35px;
height: 36px;
line-height: 36px;
text-align: center;
}
#menu label span {
font-size: 13px;
position: absolute;
left: 35px;
}
#menu ul.menus {
/*background sub menus*/
height: auto;
overflow: hidden;
width: 180px;
background-color: #333333;
position: absolute;
z-index: 99;
display: none;
border: 1px solid #000;
border-top: none;
color: #fff;
}
#menu ul.menus a {
color: #fff;
padding: 0px;
}
#menu ul.menus li {
display: block;
width: 100%;
text-transform: none;
}
#menu li:hover ul.menus {
display: block;
border-top: 2px solid red;
border-bottom: 2px solid red;
}
#menu a.prett {
padding: 14px 19px 14px 5px;
}
#menu li:hover > a.prett,#menu a.prett:hover {
/*DropDown list background color*/
background: #e1a900;
color: #fff;
}
#menu a.prett::after {
content: "";
width: 0;
height: 0;
border-width: 6px 5px;
border-style: solid;
border-color: #eee transparent transparent transparent;
position: absolute;
top: 30px;
right: 4px;
}
#menu ul.menus a:hover {
/*Dropdown menu background color*/
background: #e1a900;
}
#media screen and (max-width: 1000px){
#menu {width: 150px;}
#menu a {padding: 0px; border-bottom: 1px solid #000;}
#menu a.prett {padding: 0px;}
#menu a.prett::after {top: 15px;right: 4px;}
#menu{position:relative;margin-top:0;}
#menu ul{background-color: #333333;position:absolute;top:100%;right:0;left:0;z-index:3;height:auto;display:none;}
#menu ul.menus{width:100%;position:static;border:none; border-top: 2px solid red; border-bottom: 2px solid red;}
#menu li{display:block;float:none;width:auto;text-align:left}
#menu li a{color:#fff}
#menu li a:hover{color:#333}
#menu li:hover{background:#e1a900;color:#fff;}
#menu li:hover > a.prett,#menu a.prett:hover{background:#BABABA;color:#333;}
#menu ul.menus a{background-color: #4d4d4d;}
#menu ul.menus a:hover{background:#e1a900;}
#menu input,#menu label{position:absolute;top:0;left:0;display:block;margin-top: 15px;}
#menu input{z-index:4}
#menu input:checked + label{color:#e1a900; background-color: #404040;}
#menu input:checked ~ ul{display:block;}
}
.menu_head {
width: 100%;
height: 64px;
background-color: #000;
background-image: url("../images/menu.png");
box-shadow: 0 3px 6px rgba(0,0,0, .8);
background-position: top;
text-align: center;
padding-left: 10px;
padding-right: 10px;
position: fixed;
top: 0;
color: #fff;
z-index:1;
font-weight: bold;
border: 1px solid #fff;
}
<div class='menu_head'>
<!-- MENU LEFT -->
<nav id='menu' style='border: 1px solid #fff;'>
<input type='checkbox'/>
<label>≡<span>MENU</span></label>
<ul>
<li><a href=''>Home</a></li>
<li><a class='prett' href='' onclick='return false;'>Rules</a>
<ul class='menus'>
<li><a href='#'>Rules </a></li>
</ul>
</li>
<li><a class='prett' href='' onclick='return false;'>Suporte</a>
<ul class='menus'>
<li><a href='#'>Terms of Service</a></li>
</ul>
</li>
</ul>
</nav>
<div class='notificationicon'>
<span class='bell'>
<img class='bellimg' src='../images/notification.png'/>
<span class='bellnumbers'>10</span>
</span>
<span class='dropdown'>
<div style='float: right; line-height: 64px; margin-right:15px;'>Welcome asd asd asd asd x3G</div>
<div class='dropdown-content'>
<a href=''>PROFILE</a>
<a href=''>TEAM</a>
<a href=''> SETINGS</a>
<a href=''>BALANCE</a>
<a href=''> INBOX</a>
<a href=''> LOG OUT</a>
</div>
</span>
<div style='clear:both;'></div>
</div>
<div style='clear:both;'></div>
</div>
On the .bell class you have defined the left property value without a unit, for example px (See image below for reference)
Simply add a unit like px or % and it should work:
.bell {
left: 30px;
}
So I made a custom before pseudo line and I'm trying to figure out how to vertically align it center to my list items. How does one do that? I tried absolute positioning but it stacks all of them and places them in the middle rather than them being on each list item.
.menu {
background: #ececec;
width: 200px;
margin-top: 40px;
height: 200px;
display: flex;
justify-content: center;
align-items: center;
border-radius: 20px;
transition: 0.5s all ease-in-out;
}
.menu li {
padding: 10px 0;
cursor: pointer;
}
.menu ul {
position: relative;
}
.menu li:before {
content: '';
height: 30px;
width: 3px;
background-color: #FE715D;
left: -10px;
position: absolute;
border-radius: 20px;
opacity: 0;
transition: 0.5s all ease-in-out;
}
.menu li:hover:before {
transition: 0.5s all ease-in-out;
opacity: 1;
}
<div class="menu">
<ul>
<li class="lifirst">About Me</li>
<li class="limenu">My Skills<li class="limenu">Portfolio</li>
<li class="limenu">Contact</li>
</ul>
</div>
To prevent the stacking of the pseudo elements, you have to set a position for their corresponding parent.
absolute
The element is removed from the normal document flow; no space is created for the element in the page layout. Instead, it is positioned relative to its closest positioned ancestor if any
—position on MDN
In other words: If you add position: relative; to your <li> elements, every pseudo elements position is depending on its corresponding list item:
.menu {
background: #ececec;
width: 200px;
margin-top: 40px;
height: 200px;
display: flex;
justify-content: center;
align-items: center;
border-radius: 20px;
transition: 0.5s all ease-in-out;
}
.menu li {
padding: 10px 0;
cursor: pointer;
position: relative;
}
.menu ul {
position: relative;
}
.menu li:before {
content: '';
height: 30px;
width: 3px;
background-color: #FE715D;
left: -40px;
top: 7px;
position: absolute;
border-radius: 20px;
opacity: 0;
transition: 0.5s all ease-in-out;
}
.menu li:hover:before {
transition: 0.5s all ease-in-out;
opacity: 1;
}
<div class="menu">
<ul>
<li class="lifirst">About Me</li>
<li class="limenu">My Skills</l<li class="limenu">Portfolio</li>
<li class="limenu">Contact</li>
</ul>
</div>
I have a fixed menu bar that contains a simple <ul> <li> menu system. Upon li:hover I have a sub-menu system aside appear, and this is relative to each li. Unfortunately this aside is always appearing on top of all of the parents.
When I actually want it to be positioned behind the div#sidebar. Is this possible? I have not had much luck with z-index (including -1), any help would be appreciated!
<div id="sidebar">
<nav class="secondary">
<h2>Featured</h2>
<ul>
<li>
<a href="#">
<h3>Title</h3>
</a>
<aside class="article-card">
<h4>TITLE</h4>
<h5>TEXT</h5>
</aside>
</li>
</ul>
</nav>
</div>
ul {
list-style: none;
display: inline-block;
width: 59.6%;
margin-right: 9.1%;
float: right;
margin-bottom: 40px;
}
li {
display: block;
margin-bottom: 10px;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
#sidebar {
background: #253e40;
color: #8b8c91;
width: 215px;
height: 100%;
position: fixed;
top: 0;
bottom: 0;
right: 215px;
margin-right: -215px; /* "#sidebar" width */
z-index: 3;
}
#sidebar.active { margin-right: 0; }
#sidebar header {
font-weight: bold;
padding: 30px 20px 50px 20px;
border-bottom: 1px solid #8b8c91;
color: #8b8c91;
}
#sidebar footer {
background: none;
bottom: 40px;
padding: 0 20px;
position: absolute;
}
/* Nav */
#sidebar nav {
width: 100%;
margin: 20px 0 50px 0;
display: inline-block;
}
#sidebar ul {
width: 100%;
margin: 0;
}
#sidebar li {
margin-bottom: 0;
padding: 2px 20px;
}
#sidebar li:before {
content: none;
padding: 0;
}
.current-menu-item {
font-weight: bold;
color: #fff;
}
#sidebar a:hover {
color: #fff;
}
#sidebar nav.secondary h2 {
font-weight: bold;
color: #fff;
padding: 0 20px 15px 20px;
border-bottom: 1px solid #8b8c91;
}
#sidebar nav.secondary li {
padding: 15px 20px;
border-bottom: 1px solid #8b8c91;
}
#sidebar nav.secondary li:hover {
background: #252f37;
color: #fff;
}
/* Article Card Popout */
.article-card {
position: absolute;
background-color: #44484f;
display: inline-block;
width: 200px;
height: auto;
right: 15px;
border-left: 5px solid #be572b;
}
#sidebar nav.secondary li:hover .article-card {
right: 215px;
}
.article-card h4 {
font-weight: bold;
padding: 10px;
}
.article-card h5 {
color: #fff;
padding: 10px;
}
/* Transition animations */
#sidebar,
.article-card {
-webkit-transition: all 0.7s ease-in-out;
-moz-transition: all 0.7s ease-in-out;
-ms-transition: all 0.7s ease-in-out;
-o-transition: all 0.7s ease-in-out;
transition: all 0.7s ease-in-out;
}
Fiddle
If you really want to keep that html, you need to create a new stacking context. #sidebar has position:fixed - elements inside sidebar are treated with a new stacking context that now begins at #sidebar and not at body level any more.
Children of the sidebar cannot be positioned below #sidebar.
To solve this add another container inside sidebar that contains all the background styling and is inside the same stacking context as your slideout.
ul {
list-style: none;
display: inline-block;
width: 59.6%;
margin-right: 9.1%;
float: right;
margin-bottom: 40px;
}
li {
display: block;
margin-bottom: 10px;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
#sidebar {
background: #253e40;
color: #8b8c91;
width: 215px;
height: 100%;
position: fixed;
top: 0;
bottom: 0;
right: 215px;
margin-right: -215px; /* "#sidebar" width */
z-index: 3;
}
#sidebar.active { margin-right: 0; }
.sidebar-content {
height: 100%;
background: #253e40;
}
#sidebar header {
font-weight: bold;
padding: 30px 20px 50px 20px;
border-bottom: 1px solid #8b8c91;
color: #8b8c91;
}
#sidebar footer {
background: none;
bottom: 40px;
padding: 0 20px;
position: absolute;
}
/* Nav */
#sidebar nav {
width: 100%;
margin: 20px 0 50px 0;
display: inline-block;
}
#sidebar ul {
width: 100%;
margin: 0;
}
#sidebar li {
margin-bottom: 0;
padding: 2px 20px;
}
#sidebar li:before {
content: none;
padding: 0;
}
.current-menu-item {
font-weight: bold;
color: #fff;
}
#sidebar a:hover {
color: #fff;
}
#sidebar nav.secondary h2 {
font-weight: bold;
color: #fff;
padding: 0 20px 15px 20px;
border-bottom: 1px solid #8b8c91;
}
#sidebar nav.secondary li {
padding: 15px 20px;
border-bottom: 1px solid #8b8c91;
}
#sidebar nav.secondary li:hover {
background: #252f37;
color: #fff;
}
/* Article Card Popout */
.article-card {
position: absolute;
z-index: -1; // z index put's it below .sidebar-content
background-color: #44484f;
display: inline-block;
width: 200px;
height: auto;
right: 15px;
border-left: 5px solid #be572b;
}
#sidebar nav.secondary li:hover .article-card {
right: 215px;
}
.article-card h4 {
font-weight: bold;
padding: 10px;
}
.article-card h5 {
color: #fff;
padding: 10px;
}
/* Transition animations */
#sidebar,
.article-card {
-webkit-transition: all 0.7s ease-in-out;
-moz-transition: all 0.7s ease-in-out;
-ms-transition: all 0.7s ease-in-out;
-o-transition: all 0.7s ease-in-out;
transition: all 0.7s ease-in-out;
}
<div id="sidebar">
<div class="sidebar-content">
<nav class="secondary">
<h2>Featured</h2>
<ul>
<a href="#">
<li>Title
<aside class="article-card">
<h4>TITLE</h4>
<h5>TEXT</h5>
</aside>
</li>
</a>
</ul>
</nav>
</div>
</div>
#menu {
width: 100%;
margin: 10px auto;
}
#menu ul,
#menu li {
margin: 0 auto;
padding: 0 0;
list-style: none
}
#menu ul {
width: 100%;
}
#menu li {
float: left;
display: inline;
position: relative;
}
#menu a {
display: block;
line-height: 35px;
padding: 0 14px;
text-decoration: none;
}
#menu li a {
border-right: 1px solid #e5e5e5;
}
#menu li a:hover {
color: #444;
background-color: #e5e5e5;
}
#menu input {
display: none;
margin: 0 0;
padding: 0 0;
width: 80px;
height: 30px;
opacity: 0;
}
#menu label {
font-size: 20px;
display: none;
width: 35px;
height: 20px;
line-height: 20px;
text-align: center;
color: #77778b
}
#menu label span {
position: absolute;
left: 35px;
}
#menu ul.menus {
height: auto;
overflow: hidden;
width: 180px;
border-top: 1px solid #e5e5e5;
border-left: 1px solid #e5e5e5;
border-bottom: 1px solid #e5e5e5;
position: absolute;
z-index: 99;
display: none;
left: -1px;
}
#menu ul.menus li {
display: block;
width: 100%;
}
#menu ul.menus a {
color: #77778b;
}
#menu li:hover ul.menus {
display: block
}
<nav id='menu'>
<input type='checkbox' />
<label><i class='icon-reorder' /><span>Menu</span>
</label>
<ul>
<li><a href='/'>Home</a>
</li>
<li><a class='dropdown' href='#'>Menu1</a>
<ul class='menus'>
<li><a href='#'>Submenu1</a>
</li>
<li><a href='#'>Submenu2</a>
</li>
</ul>
</li>
<li><a class='dropdown' href='#'>Menu2</a>
<ul class='menus'>
<li><a href='#'>Submenu1</a>
</li>
<li><a href='#'>Submenu2</a>
</li>
<li><a href='#'>Submenu3</a>
</li>
</ul>
</li>
</ul>
</nav>
How can I make the Dropdowns Fade in with only CSS? A bit noobish question but still trying to understand CSS Any one have any idea how to make it possible plz suggest it.
Thanks !
One possible solution is to use opacity: 0 instead of display: none and using transition on hover:
#menu {
width: 100%;
margin: 10px auto;
}
#menu ul,
#menu li {
margin: 0 auto;
padding: 0 0;
list-style: none
}
#menu ul {
width: 100%;
}
#menu li {
float: left;
display: inline;
position: relative;
}
#menu a {
display: block;
line-height: 35px;
padding: 0 14px;
text-decoration: none;
}
#menu li a {
border-right: 1px solid #e5e5e5;
}
#menu li a:hover {
color: #444;
background-color: #e5e5e5;
}
#menu input {
display: none;
margin: 0 0;
padding: 0 0;
width: 80px;
height: 30px;
opacity: 0;
}
#menu label {
font-size: 20px;
display: block;
width: 35px;
height: 20px;
line-height: 20px;
text-align: center;
color: #77778b;
visibility: hidden;
}
#menu label span {
position: absolute;
left: 35px;
}
#menu ul.menus {
height: auto;
overflow: hidden;
width: 180px;
border-top: 1px solid #e5e5e5;
border-left: 1px solid #e5e5e5;
border-bottom: 1px solid #e5e5e5;
position: absolute;
z-index: 99;
display: block;
left: -1px;
opacity: 0;
}
#menu ul.menus li {
display: block;
width: 100%;
}
#menu ul.menus a {
color: #77778b;
}
#menu li:hover ul.menus {
opacity: 1;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
<nav id='menu'>
<input type='checkbox' />
<label><i class='icon-reorder' /><span>Menu</span>
</label>
<ul>
<li><a href='/'>Home</a>
</li>
<li><a class='dropdown' href='#'>Menu1</a>
<ul class='menus'>
<li><a href='#'>Submenu1</a>
</li>
<li><a href='#'>Submenu2</a>
</li>
</ul>
</li>
<li><a class='dropdown' href='#'>Menu2</a>
<ul class='menus'>
<li><a href='#'>Submenu1</a>
</li>
<li><a href='#'>Submenu2</a>
</li>
<li><a href='#'>Submenu3</a>
</li>
</ul>
</li>
</ul>
</nav>
Also you can use transition same way to animate on mouse out:
#menu {
width: 100%;
margin: 10px auto;
}
#menu ul,
#menu li {
margin: 0 auto;
padding: 0 0;
list-style: none
}
#menu ul {
width: 100%;
}
#menu li {
float: left;
display: inline;
position: relative;
}
#menu a {
display: block;
line-height: 35px;
padding: 0 14px;
text-decoration: none;
}
#menu li a {
border-right: 1px solid #e5e5e5;
}
#menu li a:hover {
color: #444;
background-color: #e5e5e5;
}
#menu input {
display: none;
margin: 0 0;
padding: 0 0;
width: 80px;
height: 30px;
opacity: 0;
}
#menu label {
font-size: 20px;
display: block;
width: 35px;
height: 20px;
line-height: 20px;
text-align: center;
color: #77778b;
visibility: hidden;
}
#menu label span {
position: absolute;
left: 35px;
}
#menu ul.menus {
height: auto;
overflow: hidden;
width: 180px;
border-top: 1px solid #e5e5e5;
border-left: 1px solid #e5e5e5;
border-bottom: 1px solid #e5e5e5;
position: absolute;
z-index: 99;
display: block;
left: -1px;
opacity: 0;
-webkit-transition: opacity 0.5s ease-in-out;
-moz-transition: opacity 0.5s ease-in-out;
-ms-transition: opacity 0.5s ease-in-out;
-o-transition: opacity 0.5s ease-in-out;
transition: opacity 0.5s ease-in-out;
}
#menu ul.menus li {
display: block;
width: 100%;
}
#menu ul.menus a {
color: #77778b;
}
#menu li:hover ul.menus {
opacity: 1;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
<nav id='menu'>
<input type='checkbox' />
<label><i class='icon-reorder' /><span>Menu</span>
</label>
<ul>
<li><a href='/'>Home</a>
</li>
<li><a class='dropdown' href='#'>Menu1</a>
<ul class='menus'>
<li><a href='#'>Submenu1</a>
</li>
<li><a href='#'>Submenu2</a>
</li>
</ul>
</li>
<li><a class='dropdown' href='#'>Menu2</a>
<ul class='menus'>
<li><a href='#'>Submenu1</a>
</li>
<li><a href='#'>Submenu2</a>
</li>
<li><a href='#'>Submenu3</a>
</li>
</ul>
</li>
</ul>
</nav>
I created a CSS menu with dropdown and I hide the sub menu and display it when you hover over the menu item and I was wondering if it is possible with CSS with some type of CSS transition to make it instead slide down. You cake take a look at a mock up of the menu here.
#main-nav {
position: relative;
}
#main-nav>ul>li {
width: 12.5%;
float: left;
text-align: center;
line-height: .9em;
font-weight: bold;
background: #ccc;
}
#main-nav>ul>li>a {
display: block;
color: #333;
line-height: 12px;
font-size: 14px;
padding: 22px 0;
text-decoration: none;
}
.nav-dropdown {
margin: -5px auto;
position: absolute;
left: -999em;
/* Hides the drop down */
text-align: left;
padding: 0;
border-top: 0;
width: 500px;
background: #333;
color: #f2f2f2;
border-bottom: 10px solid #25272a;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-bottomright: 5px;
-moz-border-radius-bottomleft: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
}
#main-nav li:hover .nav-dropdown {
left: 0;
top: auto;
z-index: 11;
}
<div id="main-nav">
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3
<!-- Start Blog Drop Down-->
<div class="nav-dropdown">
<p>have this item slide down from CSS</p>
</div>
<!-- /.nav-dropdown -->
</li>
</ul>
</div>
Yes you can, but you need to use the max-height property as described here or you can just use a fixed height as described in the previous answer.
CSS
.nav-dropdown {
margin: 0 auto;
height: 0; /* Hides the drop down */
overflow: hidden;
text-align:left;
padding: 0;
border-top: 0;
width: 500px;
background:#333;
color: #f2f2f2;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-bottomright: 5px;
-moz-border-radius-bottomleft: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom: 0;
max-height:0px;
}
#main-nav li:hover .nav-dropdown {
height:auto;
z-index: 11;
max-height:200px;
transition-property: all;
transition-duration: 1s;
border-bottom: 10px solid #25272a;
}
http://jsfiddle.net/L8WVP/7/
This might also be of your interest.
That should help you. Just give the div tag which should slide in the hight 0 at first and make the css transition.
-webkit-transition: height 0.5s ease-in;
-moz-transition: height 0.5s ease-in;
-o-transition: height 0.5s ease-in;
-ms-transition: height 0.5s ease-in;
transition: height 0.5s ease-in;
Then you add at the hover section the hight of the div.
#main-nav li:hover .nav-dropdown {
left: 0;
top: auto;
z-index: 11;
height:200px;
}
And you are done.
Hope I helped you.
http://jsfiddle.net/L8WVP/6/
<ul class="navigation">
<li>Home</li>
<li class="menu">
Services
<ul class="submenu">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
</ul>
</li>
<li>About</li>
<li>Contact</li>
</ul>
ul {
padding: 0;
margin: 0;
list-style: none;
}
ul li a {
text-decoration: none;
color: #e74c3c;
font-family: Tahoma, Arial;
}
.navigation {
background-color: a#e74c3c;
width: 75%;
margin: 20px auto;
min-height: 50px;
}
.navigation > li {
float: left;
padding: 0 20px;
}
.navigation > li > a {
line-height: 50px;
color: #FFF;
}
.navigation .menu {
position: relative
}
.navigation .menu .submenu {
position: absolute;
width: 200px;
-webkit-box-shadow: 0px 1px 1px #CCC;
box-shadow: 0px 1px 1px #CCC;
display: none;
-webkit-transition: all .5s ease-in-out;
-moz-transition: all .5s ease-in-out;
transition: all .5s ease-in-out;
}
.navigation .menu:hover .submenu {
display: block
}
.navigation .menu .submenu:before {
content: "";
position: absolute;
display: block;
border-width: 0 6px 6px 6px;
border-style: solid;
border-color: #FFF transparent;
top: -6px;
left: 5px
}
.navigation .menu .submenu li {
padding: 5px 10px;
-webkit-transition: all .5s ease-in-out;
-moz-transition: all .5s ease-in-out;
transition: all .5s ease-in-out;
}
.navigation .menu .submenu li:hover {
background-color: #e74c3c;
}
.navigation .menu .submenu li:hover a {
color: #FFF;
padding: 0 11px;
}