Mozilla Float Bug in XHTML Strict 1.0/CSS - html

I'm working on a project with multiple columns. The lay-out displays correctly in Chrome, IE, Opera, even Konqueror, but not in Firefox. I'm currently using Firefox 37.0.1.
The issue I'm having is that all of my div's overlap atop the background image at the top of the page when opening in Mozilla. I'd like to correct this, so that it displays as it does in Chrome, Konqueror, etc.
I've also attached images to visualize the issue.
(CORRECT DISPLAY)
(INCORRECT DISPLAY
EDIT
http://i57.tinypic.com/fp58n7.jpg
In this final image, I've applied a suggested solution of using
<div style="clear:both;"></div>
to clear the parent div of its floats, but I'm not able to get it to work the way I want it to.
Here's my CSS Code:
/* ORGANIZATION: CAL WATER WARS
AUTHOR: GEOFF HOWARD
LAST REVISED: 4/13/201 */
/* VIEWPORT RENDERING */
/* background image auto-scaling */
html {
height: 100%;
background: #99afd6;
}
body {
height: 100%;
margin: 0 auto;
background-color: #0078c4;
font-family: verdana;
font-size: .9em;
background-image: url(content.jpg);
background-repeat: no-repeat;
background-position: 320px 24px;
}
/*this creates the slow fade affect on all links */
a {
-webkit-transition:all .5s;
}
/* END VIEWPORT RENDERING */
/* LAYOUT SETUP */
/* content center + page wrapping */
#contentwrap {
width: 1024px;
height: auto;
margin: 0 auto;
/*padding-top: 200px;*/
}
/* water droplet navigation cfg */
div#sidenav {
clear: both;
padding-top: 100px;
width: 128px;
margin-left: auto;
margin-right: auto;
padding-right: 50px;
}
/* nav link transition setup */
#sidenav ul {
list-style-type: none;
}
#sidenav li a {
display: block;
background: url(water.png); /* free stock icon copyright: http://www.elegantthemes.com/ */
background-repeat: no-repeat;
background-position: center;
width: 128px;
height: 128px;
}
#sidenav li a:hover {
color: #fff;
background: url(waterhover.png); /* free stock icon copyright: http://www.elegantthemes.com/ */
background-repeat: no-repeat;
background-position: center;
width: 128px;
height: 128px;
}
/* menu frame cfg */
div#menubox {
padding-top: 200px;
width: 300px;
margin: 0px;
float: left;
height: 100%;
/*background-color: #4f5d73;*/
}
div#menubox p {
text-indent: 5em;
}
div#menubox h2 {
text-align: center;
color: #77b3d4;
text-decoration: none;
}
div#menubox h2 a:link {
text-decoration: none;
}
div#menubox h2 a:visited {
color: #77b3d4;
text-decoration: none;
}
div#menubox h2 a:hover {
color: #4f5d73;
}
/*drop down menu cfg, learned from a tutorial found at www.csswizardry.com */
#menu {
list-style: none;
font-weight: bold;
margin-bottom: 10px;
float:left;
width: 100%;
position: relative;
z-index: 5;
}
#menu li{
float: left;
margin-right: 10px;
position: relative;
text-align: center;
color: #c0d8f1;
}
#menu a {
display: block;
padding: 5px;
color:#4973AB;
background: #FFF;
text-decoration: none;
text-align: left !important;
}
#menu a:hover {
color: #4973AB;
background:#DBE9EC;
text-decoration: underline;
}
#menu ul{
background: #fff;
background: rgba(255,255,255,0);
list-style:none;
position:absolute;
left:-9999px;
}
#menu ul li{
padding-top: 1px;
float:none;
}
#menu ul a{
white-space:nowrap;
}
#menu li:hover ul{
left:0;
}
#menu li:hover a{
background:#DBE9EC;
text-decoration:underline;
}
#menu li:hover ul a{
text-decoration:none;
}
#menu li:hover ul li{
background-color: #fff;
color: #4f5d73;
}
#menu li:hover ul li a:hover{
background:#333;
}
/* story frame cfg */
div#storybox {
margin: 0px;
margin-left: 304px;
padding-left: 20px;
text-indent: 3em;
width: 700px;
background-color: rgba(119,179,212,0.7);
min-height: 100px;
max-height: 500px;
border-top: groove;
border-left: groove;
border-top-left-radius: 25px;
border-bottom-left-radius: 25px;
border-top-right-radius: 15px;
border-bottom-right-radius: 15px;
border-color: #fff;
overflow-y:scroll;
overflow-x:hidden;
color: #fff;
}
div#storybox h2 {
color: #fff;
text-align: center !important;
text-decoration: underline;
}
div#storybox h3 {
color: #d1edff;
text-align: center !important;
font-style: italic;
}
div#storybox a:link {
color: #0059FF;
text-decoration: none;
font-size: 1.3em;
}
div#storybox a:visited {
color: #0059FF;
text-decoration: none;
}
div#storybox a:hover {
color: #FFA500;
text-decoration: none;
}
/* begin scrollbar configuration, learned from stackoverflow forums */
#storybox {
scrollbar-face-color: #009cfe;
scrollbar-shadow-color: #FFFFFF;
scrollbar-highlight-color: #009cfe;
scrollbar-3dlight-color: #009cfe;
scrollbar-darkshadow-color: #FFFFFF;
scrollbar-track-color: #FFFFFF;
scrollbar-arrow-color: #009cfe;
}
#storybox::-webkit-scrollbar {
width: 10px;
}
#storybox::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(255,255,255,1);
-webkit-border-top-right-radius: 15px;
border-bottom-right-radius: 15px;
}
#storybox::-webkit-scrollbar-thumb {
-webkit-border-top-right-radius: 15px;
border-bottom-right-radius: 15px;
background: #009cfe;
-webkit-box-shadow: inset 0 0 1px rgba(255,255,255,1);
}
/* end scrollbar configuration */
/* top navigation cfg */
div#topnav {
color: #fff;
width: 1024px;
font-size: 2em;
font-family: sans-serif;
}
div#topnav ul {
list-style-type: none;
float: right;
}
div#topnav ul li {
display: block;
padding: 10px;
}
div#topnav ul li a:link {
color: #fff;
text-decoration: none;
}
div#topnav ul li a:visited {
color: #fff;
}
div#topnav ul li a:hover {
color: #4f5d73;
background-color: #fff;
}
/* END LAYOUT SETUP */
And lastly, my (X)HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- ORGANIZATION: CAL WATER WARS
AUTHOR: GEOFF HOWARD
LAST REVISED: 4/13/2015
-->
<head>
<title>California Water Wars</title>
<meta http-equiv="content-type"
content="text/html;charset=utf-8" />
<link href="test.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/r29/html5.min.js"></script>
<![endif]-->
</head>
<body>
<div id="contentwrap">
<div id="topnav">
<ul>
<li>
resources
</li>
<li>
policies
</li>
<li>
sanitation
</li>
</ul>
</div>
<div id="menubox">
<h2>
Editors
</h2>
<ul id="menu">
<li>
John Howard
<ul>
<li>
Available Stories
</li>
<li>
A Grain of Salt
</li>
<li>
Despite Drought, Water Conservation Not a Priority
</li>
</ul>
</li>
</ul>
<div id="sidenav">
<ul>
<li>
</li>
</ul>
</div>
</div>
<div id="storybox">
<h2>
Who We Are
</h2>
<p>
California Water Wars offers a snapshot of water policy and politics in California. We are a professional news team with experience covering California water issues and government, including the Legislature, the bureaucracy and the lobbying community.</p>
<p>
Since statehood – before, in fact – disputes over water have defined California; north and south, inland and coastal. The mission of California Water Wars is to inform the public and policy makers about California water issues and to suggest solutions to the problems.
</p>
</div>
</div>
</body>
</html>

Hm, nested floats. Part of the problem is caused by the clear: both inside the #menubox, which is itself floating. Firefox doesn't handle that very well. You can't really clear a floating element inside itself, only after its end. So at first I thought the solution would be to include a clear: right on #storybox, and also to change the clear: both on #sidenav to clear:right.
However, that won't work, because of those nested floats.
Therefore, your best bet is to take the #menubox out of the flow by positioning it absolutely.
#contentwrap {
(...)
position:relative; /* needed as container for abs positioning */
}
div#menubox {
(...)
position:absolute;
left:0 top:0;
}
div#storybox {
(...)
clear:right; /* and you do need this. */
}
/* ORGANIZATION: CAL WATER WARS
AUTHOR: GEOFF HOWARD
LAST REVISED: 4/13/201 */
/* VIEWPORT RENDERING */
/* background image auto-scaling */
html {
height: 100%;
background: #99afd6;
}
body {
height: 100%;
margin: 0 auto;
background-color: #0078c4;
font-family: verdana;
font-size: .9em;
background-image: url(content.jpg);
background-repeat: no-repeat;
background-position: 320px 24px;
}
/*this creates the slow fade affect on all links */
a {
-webkit-transition:all .5s;
}
/* END VIEWPORT RENDERING */
/* LAYOUT SETUP */
/* content center + page wrapping */
#contentwrap {
width: 1024px;
height: auto;
margin: 0 auto;
/*padding-top: 200px;*/
position:relative;
}
/* water droplet navigation cfg */
div#sidenav {
padding-top: 100px;
width: 128px;
margin-left: auto;
margin-right: auto;
padding-right: 50px;
}
/* nav link transition setup */
#sidenav ul {
list-style-type: none;
}
#sidenav li a {
display: block;
background: url(water.png); /* free stock icon copyright: http://www.elegantthemes.com/ */
background-repeat: no-repeat;
background-position: center;
width: 128px;
height: 128px;
}
#sidenav li a:hover {
color: #fff;
background: url(waterhover.png); /* free stock icon copyright: http://www.elegantthemes.com/ */
background-repeat: no-repeat;
background-position: center;
width: 128px;
height: 128px;
}
/* menu frame cfg */
div#menubox {
position:absolute;
left:0 top:0;
padding-top: 200px;
width: 300px;
margin: 0px;
height: 100%;
/*background-color: #4f5d73;*/
}
div#menubox p {
text-indent: 5em;
}
div#menubox h2 {
text-align: center;
color: #77b3d4;
text-decoration: none;
}
div#menubox h2 a:link {
text-decoration: none;
}
div#menubox h2 a:visited {
color: #77b3d4;
text-decoration: none;
}
div#menubox h2 a:hover {
color: #4f5d73;
}
/*drop down menu cfg, learned from a tutorial found at www.csswizardry.com */
#menu {
list-style: none;
font-weight: bold;
margin-bottom: 10px;
float:left;
width: 100%;
position: relative;
z-index: 5;
}
#menu li{
float: left;
margin-right: 10px;
position: relative;
text-align: center;
color: #c0d8f1;
}
#menu a {
display: block;
padding: 5px;
color:#4973AB;
background: #FFF;
text-decoration: none;
text-align: left !important;
}
#menu a:hover {
color: #4973AB;
background:#DBE9EC;
text-decoration: underline;
}
#menu ul{
background: #fff;
background: rgba(255,255,255,0);
list-style:none;
position:absolute;
left:-9999px;
}
#menu ul li{
padding-top: 1px;
float:none;
}
#menu ul a{
white-space:nowrap;
}
#menu li:hover ul{
left:0;
}
#menu li:hover a{
background:#DBE9EC;
text-decoration:underline;
}
#menu li:hover ul a{
text-decoration:none;
}
#menu li:hover ul li{
background-color: #fff;
color: #4f5d73;
}
#menu li:hover ul li a:hover{
background:#333;
}
/* story frame cfg */
div#storybox {
clear:right;
margin: 0px;
margin-left: 304px;
padding-left: 20px;
text-indent: 3em;
width: 700px;
background-color: rgba(119,179,212,0.7);
min-height: 100px;
max-height: 500px;
border-top: groove;
border-left: groove;
border-top-left-radius: 25px;
border-bottom-left-radius: 25px;
border-top-right-radius: 15px;
border-bottom-right-radius: 15px;
border-color: #fff;
overflow-y:scroll;
/*overflow-x:hidden;*/
color: #fff;
}
div#storybox h2 {
color: #fff;
text-align: center !important;
text-decoration: underline;
}
div#storybox h3 {
color: #d1edff;
text-align: center !important;
font-style: italic;
}
div#storybox a:link {
color: #0059FF;
text-decoration: none;
font-size: 1.3em;
}
div#storybox a:visited {
color: #0059FF;
text-decoration: none;
}
div#storybox a:hover {
color: #FFA500;
text-decoration: none;
}
/* begin scrollbar configuration, learned from stackoverflow forums */
#storybox {
scrollbar-face-color: #009cfe;
scrollbar-shadow-color: #FFFFFF;
scrollbar-highlight-color: #009cfe;
scrollbar-3dlight-color: #009cfe;
scrollbar-darkshadow-color: #FFFFFF;
scrollbar-track-color: #FFFFFF;
scrollbar-arrow-color: #009cfe;
}
#storybox::-webkit-scrollbar {
width: 10px;
}
#storybox::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(255,255,255,1);
-webkit-border-top-right-radius: 15px;
border-bottom-right-radius: 15px;
}
#storybox::-webkit-scrollbar-thumb {
-webkit-border-top-right-radius: 15px;
border-bottom-right-radius: 15px;
background: #009cfe;
-webkit-box-shadow: inset 0 0 1px rgba(255,255,255,1);
}
/* end scrollbar configuration */
/* top navigation cfg */
div#topnav {
color: #fff;
width: 1024px;
font-size: 2em;
font-family: sans-serif;
}
div#topnav ul {
list-style-type: none;
float: right;
}
div#topnav ul li {
display: block;
padding: 10px;
}
div#topnav ul li a:link {
color: #fff;
text-decoration: none;
}
div#topnav ul li a:visited {
color: #fff;
}
div#topnav ul li a:hover {
color: #4f5d73;
background-color: #fff;
}
/* END LAYOUT SETUP */
<div id="contentwrap">
<div id="topnav">
<ul>
<li>
resources
</li>
<li>
policies
</li>
<li>
sanitation
</li>
</ul>
</div>
<div id="menubox">
<h2>
Editors
</h2>
<ul id="menu">
<li>
John Howard
<ul>
<li>
Available Stories
</li>
<li>
A Grain of Salt
</li>
<li>
Despite Drought, Water Conservation Not a Priority
</li>
</ul>
</li>
</ul>
<div id="sidenav">
<ul>
<li>
</li>
</ul>
</div>
</div>
<div id="storybox">
<h2>
Who We Are
</h2>
<p>
California Water Wars offers a snapshot of water policy and politics in California. We are a professional news team with experience covering California water issues and government, including the Legislature, the bureaucracy and the lobbying community.</p>
<p>
Since statehood – before, in fact – disputes over water have defined California; north and south, inland and coastal. The mission of California Water Wars is to inform the public and policy makers about California water issues and to suggest solutions to the problems.
</p>
</div>
</div>
That's about it. You may also need to reposition other elements, which now end up under the #menubox. But that would be mostly a matter of adjusting the left margins.

Related

Why wont my nav display dropdown-links vertically?

I have been sitting for 4 hours now trying to make my nav display dropdown-links vetically but it continues to show them horizontally instead. I can´t figure out why this is happening or how to fix it.
I would appreciate it very much if some kind soul could tell me what I am doing wrong. I have a sneaking suspecion this is caused due to my settings for the nav (it changes size at a certain width) but I am not sure...
I have ripped my nav from my website and thrown everything into codepen, but even after several attempts to figure out where the problem starts - nothing! It displays "link1" right below and then just adds "link2" and "link3" to the right of it, instead of under
Please help?
Codepen: https://codepen.io/Pinchofginger/pen/BJJQgZ
If there are any oddities in the CSS it´s because I have a dropdown menu for mobile that display when you press an icon... it is not currently working either, but that a question for another time.
My HTML
<header class="mainheader">
<section id="baggrund">
<div id="mainlogo">
Sønderborg
<p> og omegns</p> Kattelaug<br />
<img class="vector" src="billeder/udklip.png" alt="Kattesilhuet"></div>
<nav>
<input type="checkbox" id="menu-checkbox" role="button" />
<label for="menu-checkbox" id="menu-button">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</label>
<div id="nav_wrap">
<ul id="menu">
<li>Forside</li>
<li>Adopter en kat</li>
<li>Tilløber katte</li>
<li> Kattens pleje</li>
<li class="dropdown">
<a href="javascript:void(0)" class="dropbtn">
Kontakt</a><div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
</ul></div>
</nav>
</section>
</header>
MY CSS
/* small nav */
#media screen and (max-width: 61em) {
#menu li {
width: 20%;
}
#menu li a {
font-size: 0.9em;
width:100%;
color:red;}
#menu ul {width:100%;}
/*sidebar*/
body#index .sidemenu .sidebar1 {padding: 0 0 0 0;}
body#index #Mega {width: 96%; height:80px;}
body#index .sidemenu .sidebar1 h3 {font-size: 0.9em;}
}
/* stor nav*/
#media screen and (min-width: 61em) {
#menu li {
width: 20%;
}
#menu li a {
font-size: 1.2em;
width:100%;
color: #505050;
}} /*slut, stor*/
#menu li {
display: inline-block;
background: none;
padding: 5px 5px 5px 5px;
}
#menu li a {
text-transform: uppercase;
transition: all .5s ease;
text-decoration: none;
text-align: center;
line-height: 55px;
display: inline-block;}
.sidemenu .pleje {font-size: 0.9em; display:inline-block }
.sidemenu .pleje h3 {color: orange;}
#mainlogo {
display: block;
}
.mainheader {
width: 100%;
}
#bannerkat { display: none;}
#menu-button { display: none;}
#menu {
display: block;
border-radius: 0;
text-align: center;
position: relative;
}
/* Navigations menuen (links osv) */
#nav_wrap {
background: #f9f4ea;
width: 100%;
white-space: nowrap;
float: left;
height: 60px;
position: relative;
margin-top: 144px;
bottom: 0;
/* overflox:hidden; */
z-index: 9999;
opacity: .9;
box-shadow: 0px 1px 4px beige;
padding: 0;
}
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;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.dropdown:hover .dropdown-content {
display: block;
}
/* højde for billed-sektion*/
.mainheader section {
min-height: 204px;
}
#mainlogo {
font-size: 37px;
color: white;
border: 7px solid white;
display: inline-block;
padding: 10px;
position: absolute;
height: 123px;
/* hvid boks*/
line-height: 25px;
top: 202px;
margin-top: -180px;
left: 50%;
width: 600px;
text-align: center;
margin-left: -300px;
text-shadow: 1px 2px 1px #000;
box-shadow: 1px 2px 1px #000;
}
/* og omegns */
#mainlogo p {
font-size: 20px;
padding: 5px;
}
.vector {
width: 60px;
margin-left: -450px;
margin-top: -36px;
}
.mainheader {
margin-top: 10px;
}
Change line 42 in css: "menu li a" to Display: block instead of Display: inline-block:
#menu li a {
text-transform: uppercase;
transition: all .5s ease;
text-decoration: none;
text-align: center;
line-height: 55px;
display: block;
}

Unwanted spacing under buttons in navigation bar

I'm new to coding websites and currently doing an assignment.
My issue is that when mousing over my navigation bar, the hover color does not fully cover the entire item. How do I solve this? Is it occurring due to my logo?
My html code:
.navigation {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: rgb(134, 35, 35);
font-family: Megrim, cursive;
font-weight: bold;
}
/* floats navigation buttons to the right */
.naviright {
float: right;
}
/*makes elements start from the left*/
.navigation li {
float: left;
}
.navigation li a {
display: block;
color: white;
text-align: center;
padding: 12px 16px;
text-decoration: none;
}
/* Change the link color to #111 (black) on hover */
.navigation li a:hover:not(.active) {
background-color: #111;
}
.navigation li a:hover:active {
background-color: #4CAF50;
}
/*TopNav End*/
/*logo*/
#logo {
width: 40px;
height: 40px;
overflow: hidden;
padding-left: 20px;
padding-bottom: 5px;
padding-top: 2px;
}
#logoname {
color: rgb(255, 255, 255);
font-size: 20px;
}
<nav>
<ul class="navigation">
<li id="logo"><img src="images\logo.svg"></li>
<li id="logoname"><a>Stationery Haven</a></li>
<div class="naviright">
<li>Home</li>
<li>Categories</li>
<li>Feedback</li>
<li>Contact Us</li>
</div>`enter code here`
</ul>
</nav>
Add line-height to li a
.navigation li a {
display: block;
color: white;
text-align: center;
padding: 12px 16px;
text-decoration: none;
line-height:22px;
}
.navigation {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: rgb(134, 35, 35);
font-family: Megrim, cursive;
font-weight: bold;
}
/* floats navigation buttons to the right */
.naviright {
float: right;
}
/*makes elements start from the left*/
.navigation li {
float: left;
}
.navigation li a {
display: block;
color: white;
text-align: center;
padding: 12px 16px;
text-decoration: none;
line-height:22px;
}
/* Change the link color to #111 (black) on hover */
.navigation li a:hover:not(.active) {
background-color: #111;
}
.navigation li a:hover:active {
background-color: #4CAF50;
}
/*TopNav End*/
/*logo*/
#logo {
width: 40px;
height: 40px;
overflow: hidden;
padding-left: 20px;
padding-bottom: 5px;
padding-top: 2px;
}
#logoname {
color: rgb(255, 255, 255);
font-size: 20px;
}
<nav>
<ul class="navigation">
<li id="logo"><img src="images\logo.svg"></li>
<li id="logoname"><a>Stationery Haven</a></li>
<div class="naviright">
<li>Home</li>
<li>Categories</li>
<li>Feedback</li>
<li>Contact Us</li>
</div>`enter code here`
</ul>
</nav>
OK I reviewed you code I think if you add or change following css code then it will be work for you:
#logo {
width: 40px;
height: 40px;
overflow: hidden;
padding-left: 20px;
padding-bottom: 4px; // Changed here 5px to 4px
padding-top: 2px;
}
.navigation li a {
display: block;
color: white;
text-align: center;
padding: 12px 16px;
line-height: 22px; // Logo test font-size: 20px; so this line need to be added
text-decoration: none;
}
1) You could solve this by increasing the size of
.naviright li a {font-size: 20px;}
2) or you could just give the line-height to -
.navigation li a {line-height: 22px;}
Here is the flex based solution I've tried Fiddle

how to add drop-down menu?

I have horizontal menu bar, and I trying to add sub menu for one of item, but I am not able to add it, Its appending to my main menu, please someone help me to where i missing
thanks
HTML
<div id="talltabs-maroon">
<ul>
<li class="first">Home <span>Page</span></li>
<li class="active"><span>About us</span></li>
<li class="dropdown"><a class="dropbtn" href="#"> <span> Report </span></a>
<ul class="dropdown-content" style="left:0">
<li>
<a href="">
<p>Valve Report</p>
</a>
</li>
<li>
<a href="">
<p>Cylinder Report</p>
</a>
</li>
</ul>
</li>
<li class="last">Contact <span>Us</span></li>
</ul>
</div>
CSS for Main menu
#talltabs-maroon {
clear: left;
float: left;
padding: 0;
border-top: 3px solid #CD324F;
width: 100%;
overflow: hidden;
font-family: Georgia, serif;
height: 90px;
position: inherit;
}
#talltabs-maroon ul {
float: left;
margin: 0;
padding: 0;
list-style: none;
position: relative;
left: 50%;
text-align: center;
}
#talltabs-maroon ul li {
display: block;
float: left;
list-style: none;
margin: 0;
padding: 0;
position: relative;
right: 50%;
}
#talltabs-maroon ul li a {
display: block;
float: left;
margin: 0 3px 0 0;
padding: 0px 10px 6px 10px;
background: #CD324F;
text-decoration: none;
color: #fff;
}
#talltabs-maroon ul li a p:hover {
color: aqua;
}
#talltabs-maroon ul li a:hover {
padding: 20px 10px 6px 10px;
color: black
}
#talltabs-maroon ul li.active a,
#talltabs-maroon ul li.active a:hover {
padding: 25px 10px 6px 10px;
border-width: 5px;
border-color: aqua;
color: aqua;
}
CSS for drop down menu i tried.
.dropbtn {
list-style-type: none;
color: white;
padding: 14px;
font-size: 14px;
border: none;
cursor: pointer;
}
.dropdown {
position: relative;
display: block;
}
.dropdown-content {
list-style-type: none;
display: none;
position: absolute;
right: 0;
/*background-color: black;*/
background-image: url('../../Images/black-olive.jpg'); /*dropdowm popup*/
min-width: 160px;
box-shadow: 0px 8px 16px 5px rgba(0,0,0,0.2);
z-index: 1;
padding-right: 2px;
margin-right: 2px;
}
.dropdown-content a {
color: white;
padding: 10px 14px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
/*background-color: gray;*/
color: black;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
/*background-color: #3e8e41;*/
}
pleas help me.
thanks
tink.
Here is my answer for same example, I changed complete css,
body {
font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
}
ul li {
display: inline-block;
margin-right: -1px;
position: relative;
padding: 15px 20px;
background: #CD324F;
cursor: pointer;
color: black;
height: 40px;
width: auto;
text-align:center;
}
ul li a{
color:black;
}
ul li:hover {
background: #CD324F;
color: #fff;
height: 45px;
}
ul li a:hover {
color: #fff;
}
ul li ul {
padding: 0;
position: absolute;
top: 68px;
left: 0;
width: 160px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
}
ul li ul li {
background: #ce5068;
display: block;
color: #CD324F;
height: 35px;
}
ul li ul li:hover {
background: #CD324F;
height: 35px;
}
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
<div style="height: 77px; width:100%; margin-top:65px;text-align:center; border-top:solid; border-top-color:#CD324F">
<ul><li>Home</li>
<li>About</li>
<li>
Portfolio
<ul>
<li>Web Design</li>
<li>Web Development</li>
<li>Illustrations</li>
</ul>
</li>
<li>Blog</li>
<li>Contact</li>
</ul>
</div>
Result: on hover portfolio, drop down will appear
Working example on JSFiddle.
I really recommend to look at bootstrap's drop down menu. It is easy to use and most things are already done for you. good luck
Here is the link: https://www.w3schools.com/bootstrap/bootstrap_dropdowns.asp
your code is bit confusing , i have created a simple demo for you how to do it.
here is my HTML code
body {
background: #212121;
font-size:22px;
line-height: 32px;
color: #ffffff;
word-wrap:break-word !important;
font-family: 'Open Sans', sans-serif;
}
h1 {
font-size: 60px;
text-align: center;
color: #FFF;
}
h3 {
font-size: 30px;
text-align: center;
color: #FFF;
}
h3 a {
color: #FFF;
}
a {
color: #FFF;
}
h1 {
margin-top: 100px;
text-align:center;
font-size:60px;
font-family: 'Bree Serif', 'serif';
}
#container {
margin: 0 auto;
}
p {
text-align: center;
}
nav {
margin: 50px 0;
background-color: #E64A19;
}
nav ul {
padding: 0;
margin: 0;
list-style: none;
position: relative;
}
nav ul li {
display:inline-block;
background-color: #E64A19;
}
nav a {
display:block;
padding:0 10px;
color:#FFF;
font-size:20px;
line-height: 60px;
text-decoration:none;
}
nav a:hover {
background-color: #000000;
}
/* Hide Dropdowns by Default */
nav ul ul {
display: none;
position: absolute;
top: 60px; /* the height of the main nav */
}
/* Display Dropdowns on Hover */
nav ul li:hover > ul {
display:inherit;
}
/* Fisrt Tier Dropdown */
nav ul ul li {
width:170px;
float:none;
display:list-item;
position: relative;
}
<div id="container">
<nav>
<ul>
<li>Home</li>
<li>WordPress
<!-- First Tier Drop Down -->
<ul>
<li>Themes</li>
<li>Plugins</li>
<li>Tutorials</li>
</ul>
</li>
<li>Web Design
<!-- First Tier Drop Down -->
<ul>
<li>Resources</li>
<li>Links</li>
<li>Tutorials
</ul>
</nav>
</div>

homepage layout for dropbox menu is weird

I'm writing a homepage and I need a dropbox menu, so I found a demo for dropbox menu from Googling. But the codes did not work properly even if I applied the demo. Its layout is quite ridiculous.
The #menubar is parallel with #site_content but I intended to place #memubar that contains dropbox menu vertically followed by #site_content. Please refer below source code for detail.
html {
height: 100%;
}
* {
margin: 0;
padding: 0;
}
body {
font: normal .80em trebuchet ms, sans-serif;
background: #EEE;
color: #5D5D5D;
}
#site_content h1 {
font: normal 140%'century gothic', arial, sans-serif;
}
a,
a:hover {
outline: none;
text-decoration: underline;
color: #000000;
}
a:hover {
text-decoration: none;
color: #747474;
}
.left {
float: left;
width: auto;
margin-right: 10px;
}
.right {
float: right;
width: auto;
margin-left: 10px;
}
.center {
display: block;
text-align: center;
margin: 20px auto;
}
blockquote {
margin: 20px 0;
padding: 10px 20px 0 20px;
border: 1px solid #E5E5DB;
background: #FFF;
}
ul li {
float: left;
display: inline-block;
position: relative;
line-height: 21px;
text-align: left;
}
ul li a {
display: block;
padding: 8px 25px;
color: #333;
text-decoration: none;
}
ul li a:hover {
color: #fff;
background: #939393;
}
ul li ul.dropdown {
min-width: 100%;
/* Set width of the dropdown */
background: #f2f2f2;
display: none;
position: absolute;
z-index: 999;
left: 0;
}
ul li:hover ul.dropdown {
display: block;
/* Display the dropdown */
}
ul li ul.dropdown li {
display: block;
}
#main,
#logo,
#menubar,
#site_content,
#footer {
margin-left: auto;
margin-right: auto;
}
#main {
padding-bottom: 20px;
}
#header {
background: transparent;
height: 170px;
}
#menubar {
height: 24px;
width: 900px;
}
#site_content {
width: 858px;
overflow: hidden;
margin: 0 auto 0 auto;
padding: 10px 20px 20px 20px;
background: #fcfcfa;
border: 15px solid #FFF;
}
#site_content h1 a {
text-decoration: none;
}
#site_content.article {
font-size: 100%
}
.sidebar {
float: right;
width: 190px;
padding: 0 15px 20px 15px;
}
.sidebar ul {
padding: 0;
list-style: none;
background: #f2f2f2;
}
.sidebar li {
list-style: none;
padding: 0 0 7px 0;
}
.sidebar li a,
.sidebar li a:hover {
padding: 0 0 0 25px;
display: block;
background: transparent url(link.png) no-repeat left center;
}
.sidebar li a.selected {
color: #444;
text-decoration: none;
}
.dropdown {
position: relative;
/** Make it fit tightly around it's children */
display: inline-block;
}
.dropdown .dropdown-menu {
position: absolute;
/**
* Set the top of the dropdown menu to be positioned 100%
* from the top of the container, and aligned to the left.
*/
top: 100%;
left: 0;
/** Allow no empty space between this and .dropdown */
margin: 0;
list-style: none;
/** Remove list bullets */
width: 100%;
/** Set the width to 100% of it's parent */
padding: 0;
}
/**
* Apply these styles to .dropdown-menu when user hovers
* over .dropdown
*/
.dropdown:hover .dropdown-menu {
/** Show dropdown menu */
display: block;
}
<!DOCTYPE HTML>
<html>
<head>
<title>main</title>
<meta name="description" content="website description" />
<meta name="keywords" content="website keywords, website keywords" />
<meta http-equiv="content-type" content="text/html; charset=windows-1252" />
<link rel="stylesheet" type="text/css" href="style/style.css?ver=1" />
</head>
<body>
<div id="main">
<div id="header">
<div id="logo">
<h1><span class="logo_colour">Homepage</span></h1>
<h2>Test</h2>
</div>
<div id="menubar">
<ul id="menu">
<li class="selected">Menu1
</li>
<li> Menu2▾
<ul class="dropdown">
<li>Home
</li>
<li>About
</li>
<li>Contact
</li>
</ul>
</li>
<li>Memu3
</li>
<li>Menu4
</li>
</ul>
</div>
</div>
<div id="site_content">
<h1>Welcome to Homepage<br/> We welcome you. <br/><br/><br/></h1>
</div>
<div id="footer">
<section align="left" class="visitor bg_white">
<b>Address:</b> Address
<br />
<b>Phone:</b> Phone
<br/>
<b>Email:</b> test#test.com
<br/>
<br/>
</section>
<p class="day">Copyright © 2016 CAS Lab. All rights reserved.</p>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="./js/common.js?ver=1"></script>
</body>
</html>
If you want nav and content side-by-side, the easiest option is to utilize flexbox. I also removed the 900px width you had set on the menu and cleaned up the dropdown positioning.
html {
height: 100%;
}
* {
margin: 0;
padding: 0;
}
body {
font: normal .80em trebuchet ms, sans-serif;
background: #EEE;
color: #5D5D5D;
}
#site_content h1 {
font: normal 140%'century gothic', arial, sans-serif;
}
a,
a:hover {
outline: none;
text-decoration: underline;
color: #000000;
}
a:hover {
text-decoration: none;
color: #747474;
}
.left {
float: left;
width: auto;
margin-right: 10px;
}
.right {
float: right;
width: auto;
margin-left: 10px;
}
.center {
display: block;
text-align: center;
margin: 20px auto;
}
blockquote {
margin: 20px 0;
padding: 10px 20px 0 20px;
border: 1px solid #E5E5DB;
background: #FFF;
}
ul li {
position: relative;
line-height: 21px;
text-align: left;
}
ul li a {
display: block;
padding: 8px 25px;
color: #333;
text-decoration: none;
}
ul li a:hover {
color: #fff;
background: #939393;
}
ul li ul.dropdown {
min-width: 100%;
/* Set width of the dropdown */
background: #f2f2f2;
display: none;
position: absolute;
z-index: 999;
right: -125px;
top: 0;
}
ul li:hover ul.dropdown {
display: block;
/* Display the dropdown */
}
ul li ul.dropdown li {
display: block;
}
#main,
#logo,
#menubar,
#site_content,
#footer {
margin-left: auto;
margin-right: auto;
}
#main {
padding-bottom: 20px;
display: flex;
flex-direction: row;
}
#header {
background: transparent;
}
#menubar {
height: 24px;
}
#site_content {
width: 858px;
overflow: hidden;
margin: 0 auto 0 auto;
padding: 10px 20px 20px 20px;
background: #fcfcfa;
border: 15px solid #FFF;
}
#site_content h1 a {
text-decoration: none;
}
#site_content.article {
font-size: 100%
}
.sidebar {
float: right;
width: 190px;
padding: 0 15px 20px 15px;
}
.sidebar ul {
padding: 0;
list-style: none;
background: #f2f2f2;
}
.sidebar li {
list-style: none;
padding: 0 0 7px 0;
}
.sidebar li a,
.sidebar li a:hover {
padding: 0 0 0 25px;
display: block;
background: transparent url(link.png) no-repeat left center;
}
.sidebar li a.selected {
color: #444;
text-decoration: none;
}
.dropdown {
position: relative;
/** Make it fit tightly around it's children */
display: inline-block;
}
.dropdown .dropdown-menu {
position: absolute;
/**
* Set the top of the dropdown menu to be positioned 100%
* from the top of the container, and aligned to the left.
*/
top: 100%;
left: 0;
/** Allow no empty space between this and .dropdown */
margin: 0;
list-style: none;
/** Remove list bullets */
width: 100%;
/** Set the width to 100% of it's parent */
padding: 0;
}
/**
* Apply these styles to .dropdown-menu when user hovers
* over .dropdown
*/
.dropdown:hover .dropdown-menu {
/** Show dropdown menu */
display: block;
}
<!DOCTYPE HTML>
<html>
<head>
<title>main</title>
<meta name="description" content="website description" />
<meta name="keywords" content="website keywords, website keywords" />
<meta http-equiv="content-type" content="text/html; charset=windows-1252" />
<link rel="stylesheet" type="text/css" href="style/style.css?ver=1" />
</head>
<body>
<div id="main">
<div id="header">
<div id="logo">
<h1><span class="logo_colour">Homepage</span></h1>
<h2>Test</h2>
</div>
<div id="menubar">
<ul id="menu">
<li class="selected">Menu1
</li>
<li> Menu2▾
<ul class="dropdown">
<li>Home
</li>
<li>About
</li>
<li>Contact
</li>
</ul>
</li>
<li>Memu3
</li>
<li>Menu4
</li>
</ul>
</div>
</div>
<div id="site_content">
<h1>Welcome to Homepage<br/> We welcome you. <br/><br/><br/></h1>
</div>
<div id="footer">
<section align="left" class="visitor bg_white">
<b>Address:</b> Address
<br />
<b>Phone:</b> Phone
<br/>
<b>Email:</b> test#test.com
<br/>
<br/>
</section>
<p class="day">Copyright © 2016 CAS Lab. All rights reserved.</p>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="./js/common.js?ver=1"></script>
</body>
</html>

How do I get rid of this line below list item when using padding?

I am having a problem where when I add padding to the list item "About Us" where it adds a line of background color down when I add padding to the list item. It is hard to explain but if you copy and paste the code into an html document and open it in a browser it will make much more sense. I am too new to these forums for it to let me post an image.
I apologize, but I am just getting into coding and so am struggling a little bit.
Thanks!
<!--Begin HTML-->
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="stylesheet.css">
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<header>
<img src="Bend-oregon-dentist.jpg">
<ul id="nav">
<li>Home</li>
<li>About Us
<ul>
<li>Our Services</li>
<li>Our Office</li>
</ul>
</li>
</ul>
</header>
</body>
</html>
<!--End HTML-->
/*BEGIN CSS*/
body {
margin: 0;
}
header {
background: rgba(8,118,71,1.00);
height: 175px;
}
#nav {
list-style: none;
text-align: center;
padding-bottom: 0px;
margin-bottom: 0px;
}
#nav li {
margin-left: 10px;
display: inline;
color: white;
font-family: verdana;
background: rgba(3, 78, 3, 0.96);
padding: 2px;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
}
#nav ul{
list-style: none;
}
#nav ul li {
display: none;
}
#nav li:hover ul {
height: 20px;
}
#nav li:hover ul li {
margin-left: 899px;
display: block;
background: rgba(174,175,185,0.9);
width: 79px;
border: 2px solid black;
border-bottom: 1px solid black;
text-align: left;
color: black;
font-size: 12px;
}
/*END CSS*/
EDIT:
Your menu needs many chages. see this updated Fiddle
#nav {
list-style: none;
text-align: center;
padding-bottom: 0px;
margin-bottom: 0px;
}
#nav li {
margin-left: 10px;
display: block;
color: white;
font-family: verdana;
background: rgba(3, 78, 3, 0.96);
padding: 10px;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
}
#nav ul {
list-style: none;
}
#nav li {
position:relative;
float:left;
}
#nav li > ul {
position:absolute;
top: 38px;
left: -50px;
width:200px;
display: none;
}
#nav li:hover > ul {
display: block;
text-align: left;
color: black;
font-size: 12px;
height:auto;
}