html - Nested 'ul' tags showing unexpected output - hidding one part of menu -
basically, idea split menu stubs 4 on left side & 2 on right side , make fixed. accordingly have written html & css, on nesting ul tag inside ul tag(for right side 2 menu stubs), menu getting shorten 2 menu stubs(which should on right side).
here html & css.
help me.
/* css document */ body {margin: 0;} ul.topnav { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; position: fixed; top: 0; width: 100%; } ul.topnav li {float: left;} ul.topnav li { display: block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; border-right:1px solid white; } ul.topnav li a:hover:not(.active) {background-color: #111;} ul.topnav li a.active {background-color: #4caf50;} ul.topnav ul.right { float: right; list-style-type: none; } @media screen , (max-width: 600px){ ul.topnav ul.right, ul.topnav li {float: none;} }color:black; }
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="styles\stylo.css"> <title> - </title> </head> <body> <ul class="topnav"> <li><a href="#">home</a></li> <li><a href="#">news</a></li> <li><a href="#">contact</a></li> <li><a href="#">about</a></li> <ul class="topnav right"> <li><a style="border-left:1px solid white;" href="#">news</a></li> <li><a href="#">contact</a></li> </ul> </ul> <div style="padding:20px;margin-top:0px;background-color:#1abc9c;height:1500px;"> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> </div> </body> </html>
you can use float
float each element left , right; both of topnav
elements 100% width, why appeared on top of 1 another. i've adjusted , few other things desired effect.
/* css document */ body { margin: 0; width: 100%; } .nav-container { background-color: #333; height: 46px; max-width: 100%; position: fixed; width: 100%; } ul.topnav { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; position: fixed; top: 0; } ul.topnav li { float: left; } ul.topnav li { display: block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; border-right: 1px solid white; } ul.topnav li a:hover:not(.active) { background-color: #111; } ul.topnav li a.active { background-color: #4caf50; } ul.topnav ul { list-style-type: none; } ul.topnav.left { left: 0; } ul.topnav.right { right: 0; } @media screen , (max-width: 600px) { ul.topnav ul.right, ul.topnav li { float: none; } }
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="styles\stylo.css"> <title>-</title> </head> <body> <div class="nav-container"> <ul class="topnav left"> <li><a href="#">home</a></li> <li><a href="#">news</a></li> <li><a href="#">contact</a></li> <li><a href="#">about</a></li> </ul> <ul class="topnav right"> <li><a style="border-left:1px solid white;" href="#">news</a></li> <li><a href="#">contact</a></li> </ul> </div> <div style="padding:20px;margin-top:0px;background-color:#1abc9c;height:1500px;"> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> <p>some text text text text..</p> </div> </body> </html>
Comments
Post a Comment