jquery - Why aren't my drop down lists working? -
doing portfolio page challenge on fcc. can use html/css/bootstrap/jquery.
problem: working on navigation bar , drop down, clickable, highlighted buttons. copied instructions w3schools here not working.
/*--drop down buttons--*/ li a, .dropbtn { display: inline-block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; } li a:hover, .dropdown:hover .dropbtn { background-color: #4caf50; } li.dropdown { display: inline-block; } .dropdown-content { display: none; position: absolute; background-color: #000000; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; /*how right:0; keep text going off screen?*/ right: 0; } .dropdown-content { color: #ffffff; padding: 12px 16px; text-decoration: none; display: block; text-align: left; } .dropdown-content a:hover {background-color: #4caf50} .dropdown:hover .dropdown-content { display: block; } <div class="container-fluid"> <!----nav bar ----> <ul> <li><a href="#home">home</a></li> <li class="dropdown" style="float:right"><a href="#about" class="dropbtn">about</a> <div class="dropdown-content"> <a href="#">contact</a> <a href="#">life in japan</a> </div> </li> <li><a href="#resume">resume</a></li> <li><a href="#projects">projects</a></li> </ul> <!---end nav bar----> </div>
this my project. code incorrect?
goal = create dropdown list "about" button. list highlight (as other nav buttons do) when hovered over.
note: codepen allows me import bootstrap , use css in separate box thats why no style tags there. css top, html follows
thank you
remove position:fixed
ul
or if want position:fixed
menu remove overflow: hidden
ul { list-style-type: none; margin: 0; padding: 0; /*----not sure overflow does--->*/ overflow: hidden; background-color: #111; /*----fixes nav bar top---*/ /*position: fixed;*/ top: 0; width: 100%; font-family: sans-serif; } li { float: left; } li { display: block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; } /*alert user current link*/ .active { background-color: #4caf50; } /*--drop down buttons--*/ li a, .dropbtn { display: inline-block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; } li a:hover, .dropdown:hover .dropbtn { background-color: red; } li.dropdown { display: inline-block; } .dropdown-content { display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); z-index: 1; right:0; } .dropdown-content { color: blue; padding: 12px 16px; text-decoration: none; display: block; text-align: left; } .dropdown-content a:hover { background-color: #00ffff; } .dropdown:hover .dropdown-content { display: block; }
<div class="container-fluid"> <!----nav bar ----> <ul> <li><a href="#home">home</a></li> <li class="dropdown" style="float:right"><a href="#about" class="dropbtn">about</a> <div class="dropdown-content"> <a href="#">contact</a> <a href="#">life in japan</a> </div> </li> <li><a href="#resume">resume</a></li> <li><a href="#projects">projects</a></li> </ul> <!---end nav bar----> </div>
Comments
Post a Comment