and girls!
i have make a CSS menu, with 2 sub-level. The second level works properly. But when some of these second level menu has a sub-menu, the background of this disapear....
Here is working example with the problem
If you go to the menu: "PARA VOCÊ" and hover "LINHAS DE CRÉDITO" you see the problem...
this is my HTML Code:
<div id="menu_principal" class="wrap">
<div class="inner clearfix">
<ul id="ja-cssmenu" class="clearfix topnav">
<li class="active">
<a href="http://www.sicoobes.net/" class="menu-item0 active first-item" id="menu1" title="Principal">
<span class="menu-title">PRINCIPAL</span>
</a>
</li>
<li class="havechildmenu-item1">
<a href="/index.php/o-sicoob" class="menu-item1 haschild" id="menu54" title="O Sicoob">
<span class="menu-title">O SICOOB</span>
</a>
<ul class="subnav">
<li>Institucional</li>
<li>Equipe
<ul class="sub_subnav">
<li>Conselho Administrativo</li>
<li>Diretoria Executiva</li>
<li>Conselho Fiscal</li>
</ul>
</li>
<li>Código de Ética</li>
<li>Demonstrações</li>
<li>Estatuto</li>
<li>Políticas</li>
<li>Regimentos</li>
</ul>
</li>
<li class="havechildmenu-item1">
<a href="/index.php/o-sicoob" class="menu-item1 haschild" id="menu54" title="O Sicoob">
<span class="menu-title">PARA VOCÊ</span>
</a>
<ul class="subnav">
<li>Conta Corrente</li>
<li>Linhas de Crédito
<ul class="sub_subnav">
<li>Financiamento Veículos e outros</li>
<li>Credito Retorno Parcelado</li>
</ul>
</li>
<li>Seguros
<ul class="sub_subnav">
<li>Vida</li>
<li>Automóvel</li>
<li>Residencial</li>
<li>Vida Mulher</li>
</ul>
</li>
<li>Soluções de Investimentos
<ul class="sub_subnav">
<li>Fundos de investimento (liquidez diária).</li>
</ul>
</li>
</ul>
</li>
<li class="havechildmenu-item1">
<a href="/index.php/o-sicoob" class="menu-item1 haschild" id="menu54" title="O Sicoob">
<span class="menu-title">PARA SUA EMPRESA</span>
</a>
</li>
</ul>
</div>
</div>
and now, the CSS:
#menu_principal{
bottom:0;
position:relative;
margin:0 auto;
width:980px;
height:35px;
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
background-image:url(imagens/menu_bg.gif);
background-position:50% 0;
background-repeat:no-repeat no-repeat;
}
.wrap {
clear:both;
width:100%;
}
.clearfix{
display:block;
}
ul.topnav {
float:left;
margin:0;
padding:0;
}
ul.topnav {
list-style-image:initial;
list-style-position:initial;
list-style-type:none;
}
ul.topnav li {
background-image:url(imagens/sep.gif);
background-position:100% 0;
background-repeat:no-repeat no-repeat;
cursor:pointer;
display:block;
float:left;
height:35px;
margin:0;
padding:0;
cursor:pointer;
}
ul.topnav li a {
color:#FFFFFF;
display:block;
font-family:'Trebuchet MS', Arial, Helvetica, sans-serif;
font-weight:bold;
height:35px;
margin:0;
padding-bottom:0;
padding-left:15px;
padding-right:15px;
padding-top:0;
text-decoration:none;
text-transform:uppercase;
}
ul.topnav span.menu-title {
text-shadow:#111111 0 1px 0;
}
ul.topnav span.menu-title {
display:block;
font-size:110%;
padding-top:8px;
}
ul.topnav li a.first-item {
border-left-color:initial;
border-left-style:initial;
border-left-width:0;
}
ul.topnav li:hover, ul.topnav li a.active{
background-image:url(imagens/bg_itens_menu.gif);
background-position:-15px -48px;
}
ul.topnav li a.active.first-item {
background-position:-403px -48px;
}
ul.topnav li ul.subnav {
list-style: none;
background: #333;
margin: 0; padding: 0;
display: none;
width: 200px;
border: 1px solid #111;
position: absolute;
}
ul.topnav li:hover ul.subnav{
display: block;
padding: 0;
width: 200px;
}
ul.topnav li ul.subnav li{
margin: 0; padding:0;
border-top: 1px solid #252525;
border-bottom: 1px solid #444;
width: 200px;
}
ul.topnav li ul.subnav li a{
margin-top:8px;
color: #fff;
height:35px;
}
ul.topnav li ul.subnav li:hover{
text-shadow:#111111 0 1px 0;
}
ul.topnav li ul.subnav li ul.sub_subnav{
list-style: none;
left:201px;
top:-45px;
margin:0;
padding:0;
display:none;
width:300px;
border:1px solid #111;
background-color: #333333;
position:relative;
}
ul.topnav li ul.subnav li:hover ul.sub_subnav{
display: block;
}
ul.topnav li ul.subnav li ul.sub_subnav li{
margin: 0; padding:0;
border-top: 1px solid #252525;
border-bottom: 1px solid #444;
width: 300px;
}
thanks for help!
Remove float from your .sub_subnav li. Write like this:
ul.topnav li ul.subnav li ul.sub_subnav li {
float: none;
}
OR
you can write like this:
ul.topnav > li{
float:left;
}
You have a float set to left on ul.topnav li, this should be set only on ul.topnav > li
PS : you don't need subnav or sub_subnav classes since you can use css selectors to handle this
Related
I have two div-classes named .logo and .menu class within header-bottom class div.
<header class="header-bottom">
<div class="logo">
<img src="images/logo.png" alt="REVELATION" />
</div>
<nav class="menu">
<ul>
<li class="current">homepage</li>
<li>site demo</li>
<li>full width</li>
<li>portfolio</li>
<li>gallery</li>
<li>dropdown</li>
</ul>
</nav>
Now the problem is, when I change my browser window or zooming, then the .logo and .menu classes contents overlapped with each other. If I set width in logo then the problem was solved but I want another simple approached to hole the whole .logo class div even if not having no contents.
box-sizing, positioning may solved the problem but how? I don't know.
*{
margin:0 ;
padding:0;
}
/* hedaer bottom*/
.header-bottom
{
padding-top:40px;
overflow:hidden;
}
.header-bottom .logo
{
width:15%;
float:left;
display: inline-block;
}
.header-bottom .menu
{
width:85%;
float:left;
}
.header-bottom .menu ul
{
list-style:none;
float:right;
margin-top:15px;
padding-right:12px;
}
.header-bottom .menu ul li
{
float:left;
padding-bottom:10px;
padding-right:10px;
border-bottom:1px solid #ededed;
}
.header-bottom .menu ul li:last-child
{
padding-right:0px;
}
.header-bottom .menu ul li a
{
text-decoration:none;
font-family:Georgia Regular;
font-size:13px;
font-weight:normal;
color:#55415f;
text-transform:uppercase;
/* border-bottom:2px solid transparent;*/
}
.header-bottom .menu ul li a:hover
{
padding-bottom:10px;
border-bottom:2px solid #55415f;
}
.header-bottom .menu .current a
{
border-bottom:2px solid #55415f;
padding-bottom:10px;
}
Here is a start using Flexbox.
The display: flex set on the .header-bottom will make the .logo and .menu stay side-by-side, like table cells, and the flex-grow: 1 set on the .menu makes the .menu take the space left, that is not occupied by the .logo
Finally, with the align-items: center set on the .header-bottom you don't need top/bottom padding to center the .logo and the .menu, align-items does it for you, similar to what vertical-align: middle does to inline elements.
* {
margin: 0;
padding: 0;
}
/* hedaer bottom*/
.header-bottom {
padding-top: 40px;
overflow: hidden;
display: flex;
align-items: center;
}
.header-bottom .logo {
padding-right:10px;
}
.header-bottom .menu {
flex-grow: 1;
}
.header-bottom .menu ul {
display: flex;
flex-wrap: wrap;
align-items: center;
list-style: none;
}
.header-bottom .menu ul li {
border-bottom: 1px solid #ededed;
padding-right:10px;
}
.header-bottom .menu ul li:last-child {
}
.header-bottom .menu ul li a {
text-decoration: none;
font-family: Georgia Regular;
font-size: 13px;
font-weight: normal;
color: #55415f;
text-transform: uppercase;
/* border-bottom:2px solid transparent;*/
}
.header-bottom .menu ul li a:hover {
border-bottom: 2px solid #55415f;
}
.header-bottom .menu .current a {
border-bottom: 2px solid #55415f;
}
<header class="header-bottom">
<div class="logo">
<img src="images/logo.png" alt="REVELATION" />
</div>
<nav class="menu">
<ul>
<li class="current">homepage</li>
<li>site demo</li>
<li>full width</li>
<li>portfolio</li>
<li>gallery</li>
<li>dropdown</li>
</ul>
</nav>
I'm putting up a site on Tumblr for my online store. Thing is, I can't get the dropdown menu to show up when I put "overflow:hidden" on the #topmenu part. When I set it to "overflow:visible", I get a huge chunk of white space to the right of the webpage. The white space isn't obvious when I'm using my laptop but it is when I use my phone.
I've tried changing the value of the z-index but it still won't work. I want to be able to have "overflow:visible" while not getting the white space at the right side of the page.
Please help me figure out what's wrong with the code and find a solution. I think there's something wrong with the width of the menu. But then when I change the width, all the links are pushed to the left side of the page.
Thank you in advance!
#topmenu {
font-family: 'Montserrat', sans-serif;
float:left;
width:100%;
background:transparent;
overflow:visible;
z-index:99999;
position:relative;
}
#topmenu ul {
clear:left;
float:left;
list-style:none;
margin:0;
padding:0;
position:relative;
left:50%;
text-align:center;
}
#topmenu ul li {
display:block;
float:left;
list-style:none;
margin:0;
padding:3pt;
position:relative;
right:50%;
}
#topmenu ul li a {
display:block;
margin:0 0 0 1px;
padding:4px 11px;
background: transparent;
color: #222222;
font-size:10px;
text-decoration:none;
line-height:2em;
letter-spacing: 3px;
}
#topmenu ul li a:hover {
background: none;
color: #b492a8;
}
#topmenu ul li ul.dropdown{
min-width: 125px;
max-width: 125px;
background: #ffffff;
display: none;
position: absolute;
z-index: 999;
left: 0;
}
#topmenu ul li:hover ul.dropdown{
display: block; /* Display the dropdown */
padding:0px 0px 0px 50px;
}
#topmenu ul li ul.dropdown li{
display: block;
}
<div id="topmenu">
<ul>
<li>HOME</li>
<li>SHOP</li>
<li>FAQ</li>
<li>ORDER FORM</li>
<li>CUSTOMERS
<ul class="dropdown">
<li>OOTD</li>
<li>Feedbacks</li>
</ul>
</li>
<li>ABOUT</li>
</ul>
</div>
EDIT:
I tried using #gopalraju's code and it eliminated the white space while showing the dropdown menu. (Thank you gopalraju!)
How do I push the whole menu to the center of the page?
And how do I put the dropdown menu right under the word "Customers"?
#topmenu {
font-family: 'Montserrat', sans-serif;
float:left;
width:100%;
background:transparent;
overflow:visible;
z-index:99999;
position:relative;
}
#topmenu ul {
clear:left;
list-style:none;
margin:0;
padding:0;
position:relative;
display:table;
margin:0 auto;
text-align:center;
}
#topmenu ul li {
display:block;
float:left;
list-style:none;
margin:0;
padding:3pt;
position:relative;
}
#topmenu ul li a {
display:block;
margin:0 0 0 1px;
padding:4px 11px;
background: transparent;
color: #222222;
font-size:10px;
text-decoration:none;
line-height:2em;
letter-spacing: 3px;
}
#topmenu ul li a:hover {
background: none;
color: #b492a8;
}
#topmenu ul li ul.dropdown{
min-width: 125px;
max-width: 125px;
background: #ffffff;
display: none;
position: absolute;
z-index: 999;
left: 0;
}
#topmenu ul li:hover ul.dropdown{
display: block; /* Display the dropdown */
}
#topmenu ul li ul.dropdown li{
display: block;
}
<div id="topmenu">
<ul>
<li>HOME</li>
<li>SHOP</li>
<li>FAQ</li>
<li>ORDER FORM</li>
<li>CUSTOMERS
<ul class="dropdown">
<li>OOTD</li>
<li>Feedbacks</li>
</ul>
</li>
<li>ABOUT</li>
</ul>
</div>
I am creating a vertical navigation menu using ul and li I want to make span the full width of ul so I can have underline for each menu item (like this site (http://www.steffenallen.com/index.php))
However, there is a space in li that prevents it from spanning across the parent ul. Could someone tell me how the above website did it? Or, what I need to do?
<nav>
<ul class='menu'>
<li class="menuItem">
About
</li>
<li class="menuItem"> Album
<ul class="submenu">
<li class="submenu-Item">Nepal </li>
<li class="submenu-Item">Seattle</li>
<li class="submenu-Item">South Korea</li>
</ul>
</li>
<li class="menuItem"> Contact </li>
<!-- <li> </li> -->
</ul>
My CSS is
ul,li{
list-style: none;
display: block;
}
ul.menu{
width: 170px;
/*position: absolute;*/
/*width: 100%;*/
/*margin-left: -20px;*/
border: 1px solid orange;
}
ul.submenu{
/*position: absolute;*/
/*left: -999px;*/
/*visibility: hidden;*/
display: none;
}
li{
width:140px;
margin: 0;
padding: 0;
/*width:100%;*/
border-left: 1px blue solid;
border-right: 1px blue solid;
}
span{
display: block;
}
li a, li span {
/*width: 170px;*/
/*width: 100%;*/
border-bottom: #cbcbcb 1px solid;
}
li.menuItem, li.submenu-Item{
text-align: right;
margin: 1em 0em 1em 0em;
}
li.menuitem > a{
color: #808080;
}
li a:hover{
color: steelblue;
}
li.menuItem a.current{
background-color: orange;
}
ul.menu:first-child{
margin-top: 0
}
First things first, your CSS is not well-written and hence a little difficult to understand.
The main problem in your code happens to be the default CSS that is being applied. You can remove that as follows:
ul, li {
margin: 0;
padding: 0;
}
However, I'd suggest you simplify your CSS code as follows. This will still achieve what you are looking for all the while making your code more elegant and easily readable. Please see the code below :
ul, li {
margin:0px;
padding:0px;
}
ul.menu {
border: 1px solid Orange;
width:200px;
}
ul.menu li {
display:block;
list-style-type:none;
}
ul.menu li a {
border-bottom:1px solid #ccc;
display:block;
text-align:right;
text-decoration: none;
}
ul.menu li ul {
display:none;
}
ul.menu li:hover > ul {
display:block;
}
ul.menu li ul li:last-child {
border-bottom:none;
}
See this working below :
ul, li {
margin:0px;
padding:0px;
}
ul.menu {
border: 1px solid Orange;
width:200px;
}
ul.menu li {
display:block;
list-style-type:none;
}
ul.menu li a {
border-bottom:1px solid #ccc;
display:block;
text-align:right;
text-decoration: none;
}
ul.menu li ul {
display:none;
}
ul.menu li:hover > ul {
display:block;
}
ul.menu li ul li:last-child {
border-bottom:none;
}
<nav>
<ul class='menu'>
<li class="menuItem"> About
</li>
<li class="menuItem"> Album
<ul class="submenu">
<li class="submenu-Item">Nepal
</li>
<li class="submenu-Item">Seattle
</li>
<li class="submenu-Item">South Korea
</li>
</ul>
</li>
<li class="menuItem"> Contact
</li>
<!-- <li> </li> -->
</ul>
Hope this helps!!!
On the left side there is the default margin/padding of ULs, so just remove that. It's 40px and depends on browser if margin or padding is used.
ul, li {margin-left: 0; padding-left: 0;}
The space on the right side is caused by your widths, list has 170px, items just 140px.
http://jsfiddle.net/8q9chvbh/
I am making a test site, and I made it with no drop down menu. It looks like this: http://wrzuc.se/images/52c72647ec30e.png
My Site: http://crafted2.ugu.pl/cn2/
But, now I want to add simple drop down to "serwery". What's wrong in my code ?
HTML:
<!-- MENU CRAFTED NETWORK --->
<div class="menu">
<div id="nav">
<img class="steve" src="images/steve.png"/>
<ul>
<li>STRONA GŁÓWNA</li>
<li><img style="splitter" src="/CN/images/nav_splitter.png"></li>
<li>SERWERY
<ul>
<li><i class="icon-chevron-right"></i>Official Survival Games</li>
<li><i class="icon-chevron-right"></i>Trouble in Mineville</li>
<li><i class="icon-chevron-right"></i>The Herobrine</li>
<li><i class="icon-chevron-right"></i>Hide and Seek</li>
<li><i class="icon-chevron-right"></i>Splegg</li>
<li><i class="icon-chevron-right"></i>One In The Chamber</li>
</ul>
</li>
<li><img style="splitter" src="/CN/images/nav_splitter.png"></li>
<li>FORUM</li>
<li><img src="/CN/images/nav_splitter.png"></li>
<li>SKLEP SMS</li>
<li><img src="/CN/images/nav_splitter.png"></li>
<li>FAQ</li>
</ul>
</div>
<div class="ip"><p>IP: CRAFTED.PL</p></div>
<div class="statystyki">
<p>DOŁĄCZ DO <b>1267</b> GRACZY ONLINE!</p>
<img src="images/email.png" alt="">
<img src="images/youtube.png" alt="">
<img src="images/facebook.png" alt="">
</div><!-- KONIEC MENU -->
CSS:
.menu {
padding: 0;
margin: 0;
border: 0;
height: 132px;
position:absolute;
top: 320px;
background: url(../images/menu.png) repeat-x;
width: 100%;
}
#navi select {
display:none;
padding:4px 8px;
border: 1px dotted #CCC;
margin:3px 0px 5px 0px;
font-family: Crafted;
color: #807f7f;
font-size:10pt;
font-weight:normal;
text-decoration:none;
}
.ip {background:url('../images/ip.png') no-repeat;margin:11px 0 0 0;width:215px;height:50px;float:right;}
.ip p{font-family:Crafted;font-size:31px;color:#fff;text-align:center;width:100%;height:30px;margin:1px 0 0 0;float:left;padding-left:15px;}
.statystyki p{font-family:Crafted;font-size:40px;color:#fff;width:100%;height:30px;margin:10px 0 0 0;float:left;padding-left:70px;}
.social2 {margin: -40px 0 0 0;float: right;position: relative;width: auto;height: auto;}
.social2:hover{opacity:0.8;}
.social {margin: -40px 0 0 0;float: right;margin-right: 60px;position: relative;width: auto;height: auto;}
.social:hover{opacity:0.8;}
.steve {
margin: -79px 0 0 0;
background: url(../images/steve.png) repeat-x;
position: absolute;
margin-left: 700px;
float: left;
}
#navi {
float:left;
padding-left: 60px;
}
#navi ul {
float:left;
padding:0px;
margin:0px;
}
#navi ul li {
float:left;
top: 10px;
display:inline-block;
padding:12px 12px 13px 12px;
list-style-type: none;
position:relative;
}
#navi ul li:first-child{
float:left;
display:inline-block;
padding:12px 12px 13px 12px;
list-style-type: none;
position:relative;
}
#navi ul li a, #navi ul li a:visited{
font-family: Crafted;
color: #044B55;
font-size:22px;
font-weight:normal;
text-decoration:none;
}
#navi ul li a:hover{
font-family: 'Crafted',Arial, Helvetica, sans-serif;
color: #006775;
font-weight:normal;
text-decoration:none;
}
#navi ul li ul{
position:absolute;
display: none;
z-index: 2000;
padding-top:13px;
margin-left:-13px;
background-color:white;
}
#navi ul ul li {
float: none;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
#navi ul ul li a {
padding: 15px 40px;
color: #fff;
}
I was getting code to make dropdown from: www.threestyles.com/tutorials/css-drop-down-navigation-tutorial/
Please help me to make it work, and look like my old picture.
Your id is nav and not #navi, right?
display:none to the dropdown menu (as you have it) and then, add a class here in the "serwery" li:
<li class="serwery">SERWERY
Then you display: block the secondary menu on hover:
.serwery:hover > ul {
display: block;
position: absolute;
...
}
I've tried making horizontal drop down navigation bars following tutorials, however they are never centered and I can't figure out how to center them. I tried going in the opposite direction and centering my navigation bar first, and then attempting to make it a drop down menu, though this seems to throw everything off. This is the code I have.
EDIT: The problem I am having is that the submenu is displayed when the page is loaded, along with a bullet point, which I'm sure can be fixed by setting the list-style to none, however I'm not sure where in the CSS this should be.
I'm trying to create a menu similar to THIS. I understand this uses joomla and I am not.
#header {
height: 100px;
margin-left: auto;
margin-right: auto;
text-align: center;
}
#content {
max-width: 700px;
margin-left: auto;
margin-right: auto;
padding: 20px;
}
#footer {
height: 85px;
padding-top: 40px;
margin-left: auto;
margin-right: auto;
text-align: center;
}
#menu {
margin: 0 auto;
display: inline-block;
list-style: none;
padding: 0;
border-top: 1 solid #ccc;
border-left: 1 solid #ccc;
border-bottom: 1 solid #ccc;
}
#menu li {
float: left;
}
#menu li a {
display: block;
padding: 10px 10px;
text-decoration: none;
font-weight: bold;
}
#menu li a:hover {
color: #c00;
}
<ul id="menu">
<li>Home
</li>
<li>Kandi
<ul>
<li>Claim Kandi
</li>
</li>
<li>Events
</li>
<li>Artists
</li>
<li>Community
</li>
<li>Merchandise
</li>
</ul>
Add this CSS:
#menu, #menu ul {
margin:0 auto;
padding:0;
}
#menu li {
float: left;
position: relative;
list-style: none;
}
#menu > li:hover > ul {
display: block;
}
#menu > li > ul {
display: none;
position: absolute;
}
#menu li a {
white-space: nowrap;
}
http://jsfiddle.net/tcKvH/1/
use this css
#menu{
position:absolute;
top:150px;
left:8%;
padding:0;
margin:0;
}
#menu ul{
padding:0;
margin:0;
line-height:30px;
}
#menu li{
position:relative;
float:left;
list-style:none;
background:rgba(0,0,0,1);
border-radius:5px;
}
#menu ul ul{
position:absolute;
visibility:hidden;
padding:0;
margin:0;
top:30px;
}
#menu ul li a{
text-align:center;
font:"Arial Black", Arial;
font-size:24px;
color:rgba(255,255,255,9);
width:150px;
height:30px;
display:block;
text-decoration:none;
}
#menu ul li:hover{
background-color:rgba(128,128,128,1);
text-decoration:none;
}
#menu ul li:hover ul{
visibility:visible;
z-index:1;
}
#menu ul li:hover ul li a{
background:rgba(0,0,0,9);
z-index:1;
border-bottom:1px solid rgba(160,160,164,1);
opacity:0.9;
text-decoration:none;
border-radius:5px;
}
#menu ul li ul li:hover{
background:rgba(128,128,128,1);
opacity:0.8;
text-decoration:underline;
}
with this html code
<div id="menu">
<ul>
<li>Home</li></ul>
<ul>
<li>Video <!--This is in main menu-->
<ul>
<li>Technology</li> <!--This is in drop downmenu-->
<li>Tutorial</li> <!--This is in drop downmenu-->
</ul>
</li>
</ul>