css clearfix isnt working as it supposed to be - html

I have to floated elements in my div, I used clearfix I found in internet, but it isn't working as it should.
<div id="header" class="clear">
<div class="header-left"> </div>
<div class="header-right">
<div class="quick-drop">
<ul>
<li class="quicklinks">Quicklinks
<img src="images/quicklink-icon.png" />
</li>
<li class="dropdown">Select from dropdown
<img src="images/dropdown-icon.png" />
</li>
</ul>
</div>
<div class="search-block">
<input type="text" class="search" name="search" placeholder="Search for something here" />
</div>
</div>
<div class="header-nav">it should be below but it is under</div>
</div>
CSS
.clear:before, .clear:after {
content:"\0020";
display: block;
height: 0;
overflow: hidden;
}
.clear:after {
clear: both;
}
.header-left {
float:left;
margin:40px 0;
}
.header-right {
float:right;
margin:40px 0;
}
.logo {
background:url('../images/logo.png') no-repeat;
width:250px;
height:50px;
display:block;
}
.quick-drop {
display:inline-block;
}
.quick-drop ul {
margin:0;
padding:0;
margin:18px 0;
}
.quick-drop ul li {
list-style-type:none;
display:inline-block;
height:19px;
padding:3px;
text-align:center;
font-size:12pt;
}
ul .quicklinks {
color:#c7c7c7;
border-right:1px #c7c7c7 solid;
}
ul .dropdown {
color:#58159b;
}
.quick-drop ul li img {
margin:0 15px;
}
.search-block {
display:inline-block;
}
.search {
background:url('../images/search-icon.png') right no-repeat #fff;
background-position:260px;
width:260px;
height:16px;
border:none;
outline-color:#58159b;
padding:15px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
color:#c7c7c7;
}
http://jsfiddle.net/qKFAc
The .header-nav should be below the 2 divs, but it is under them, what I'm doing wrong?
Thank you.

Clear fixes should be AFTER the floated elements, like so:
Remove the clear class from the parent. Then:
<!-- Floated -->
<div class="clear"></div>
<div class="header-nav">it should be below but it is under</div>

.header-nav
{
clear:left;
}
please add this css rule

Add this:
.clear {
clear: both;
}
jsFiddle: http://jsfiddle.net/qKFAc/1/

Related

Content of one div overlapping on another?

Following is the all in one code i.e. html and style. Question is that why the "Box" div is being overlapped on to the "Footer" div. You can copy paste the code and see it yourself in the browser. I have checked the styles and div's starting and ending myself by so far no success. Am i missing something?
.shell { width:950px; margin:0; position:relative; }
#main { background:#f8f8f8 url(images/main.jpg) left top repeat-x; }
#main .box { float:left; width:306px; padding:0 19px 0 0; }
#main .shell { padding:25px 0; }
#footer { background:url(images/footer.jpg) left top repeat-x; color:#b3adad; padding:24px 4px; font-size:10px; }
#footer a { color:#b3adad; text-decoration:none; }
#footer a:hover { text-decoration:underline; }
#footer .footer-navigation { }
#footer .footer-navigation ul { list-style:none; }
#footer .footer-navigation ul li { float:left; padding-right:8px; margin-right:8px; border-right:1px solid #b3adad; height:10px; line-height:10px; }
#footer .footer-navigation ul li.last { padding-right:0; margin-right:0; border-right:0; }
#footer .footer-navigation ul li a { }
#footer .right { float:right; font-family:Verdana, Arial, Sans-Serif; }
#footer .right a { color:#dad7d7; font-weight:bold; text-decoration:underline; }
#footer .right a:hover { text-decoration:none; }
.box { float:left; width:306px; padding:0 19px 0 0; }
.last-box { padding-right:0; }
.box .entry { height:217px; padding-left:2px; }
.box .big-image { padding:4px 0 10px 0; }
.box .big-image img { border:2px solid #fff; }
.box .buttons .button,
.box .buttons .button span { background:url(images/main-button.jpg) repeat-x; height:29px; line-height:29px; float:right; display:inline; border:1px solid #bfbebe; padding:0 8px; }
.box .buttons .button span { float:left; border:0; background:url(images/main-button-span.jpg) left top no-repeat; padding:0 0 0 7px; }
<div id="main">
<div class="shell">
<div class="box">
<h2 style="color:#565656;">Latest News</h2>
<div class="entry">
<div class="news">
newsstring;
</div>
</div>
</div>
<div class="box">
</div>
</div>
</div>
<!-- End of Main -->
<!-- Footer -->
<div id="footer">
<div class="shell">
<div class="footer-navigation">
<ul>
<li>Home</li>
<li>About</li>
<li>Gallery</li>
<li>Location</li>
<li class="last">Contact</li>
</ul>
</div>
<div class="container">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="height:10px; width:1000px">
<tbody>
<tr>
<td style="height:75px; text-align:center; vertical-align:middle; width:560px">
<p><img alt="Seertech Solutions Pvt. Ltd" src="./css/images/seertechbanner.jpg" style="height:55px; width:660px" /></p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Just add "display: inline-block" and "width:100%" in your main div and footer.
CSS:
#footer, #main {
display: inline-block;
width: 100%;
}
Add class .clr to element has class .shell as below:
CSS
.clr:after {
content: "";
display: block;
clear: both;
height: 0;
margin: 0;
padding: 0;
}
HTML
...
<div class="shell clr">
...
Jsfiddle:
https://jsfiddle.net/merLdd2y/
.shell { width:950px; margin:0; position:relative; }
#main { background:#f8f8f8 url(images/main.jpg) left top repeat-x; }
#main .box { float:left; width:306px; padding:0 19px 0 0; }
#main .shell { padding:25px 0; }
#footer { background:url(images/footer.jpg) left top repeat-x; color:#b3adad; padding:24px 4px; font-size:10px; }
#footer a { color:#b3adad; text-decoration:none; }
#footer a:hover { text-decoration:underline; }
#footer .footer-navigation { }
#footer .footer-navigation ul { list-style:none; }
#footer .footer-navigation ul li { float:left; padding-right:8px; margin-right:8px; border-right:1px solid #b3adad; height:10px; line-height:10px; }
#footer .footer-navigation ul li.last { padding-right:0; margin-right:0; border-right:0; }
#footer .footer-navigation ul li a { }
#footer .right { float:right; font-family:Verdana, Arial, Sans-Serif; }
#footer .right a { color:#dad7d7; font-weight:bold; text-decoration:underline; }
#footer .right a:hover { text-decoration:none; }
.box { float:left; width:306px; padding:0 19px 0 0; }
.last-box { padding-right:0; }
.box .entry { height:217px; padding-left:2px; }
.box .big-image { padding:4px 0 10px 0; }
.box .big-image img { border:2px solid #fff; }
.box .buttons .button,
.box .buttons .button span { background:url(images/main-button.jpg) repeat-x; height:29px; line-height:29px; float:right; display:inline; border:1px solid #bfbebe; padding:0 8px; }
.box .buttons .button span { float:left; border:0; background:url(images/main-button-span.jpg) left top no-repeat; padding:0 0 0 7px; }
<div id="main" style="display:inline; width:100%">
<div class="shell">
<div class="box">
<h2 style="color:#565656;">Latest News</h2>
<div class="entry">
<div class="news">
newsstring;
</div>
</div>
</div>
<div class="box">
</div>
</div>
</div>
<!-- End of Main -->
<!-- Footer -->
<div id="footer">
<div class="shell">
<div class="footer-navigation">
<ul>
<li>Home</li>
<li>About</li>
<li>Gallery</li>
<li>Location</li>
<li class="last">Contact</li>
</ul>
</div>
<div class="container">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="height:10px; width:1000px">
<tbody>
<tr>
<td style="height:75px; text-align:center; vertical-align:middle; width:560px">
<p><img alt="Seertech Solutions Pvt. Ltd" src="./css/images/seertechbanner.jpg" style="height:55px; width:660px" /></p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
You're not properly clearing your floats.
#footer {
background: url(images/footer.jpg) left top repeat-x;
color: #b3adad;
padding: 24px 4px;
font-size: 10px;
clear: both;
}
This will clear the floats of the header.
You can also create the following class and add that to the parent of any container containing floated elements.
.clearFix:after {display: table; clear: both; content: "";}
An element will float around the next content found in the flow, in this case, footer's text. Check this link for more info about floats: https://css-tricks.com/all-about-floats/
In this case, depending on what you plan for your .shell i would add the following style:
.shell:after {
content: ' ';
display: table;
clear: both;
}
.shell { width:950px; margin:0; position:relative; }
.shell:after {content: ' '; display: table; clear: both;}
#main { background:#f8f8f8 url(images/main.jpg) left top repeat-x; }
#main .box { float:left; width:306px; padding:0 19px 0 0; }
#main .shell { padding:25px 0; }
#footer { background:url(images/footer.jpg) left top repeat-x; color:#b3adad; padding:24px 4px; font-size:10px; }
#footer a { color:#b3adad; text-decoration:none; }
#footer a:hover { text-decoration:underline; }
#footer .footer-navigation { }
#footer .footer-navigation ul { list-style:none; }
#footer .footer-navigation ul li { float:left; padding-right:8px; margin-right:8px; border-right:1px solid #b3adad; height:10px; line-height:10px; }
#footer .footer-navigation ul li.last { padding-right:0; margin-right:0; border-right:0; }
#footer .footer-navigation ul li a { }
#footer .right { float:right; font-family:Verdana, Arial, Sans-Serif; }
#footer .right a { color:#dad7d7; font-weight:bold; text-decoration:underline; }
#footer .right a:hover { text-decoration:none; }
.box { float:left; width:306px; padding:0 19px 0 0; }
.last-box { padding-right:0; }
.box .entry { height:217px; padding-left:2px; }
.box .big-image { padding:4px 0 10px 0; }
.box .big-image img { border:2px solid #fff; }
.box .buttons .button,
.box .buttons .button span { background:url(images/main-button.jpg) repeat-x; height:29px; line-height:29px; float:right; display:inline; border:1px solid #bfbebe; padding:0 8px; }
.box .buttons .button span { float:left; border:0; background:url(images/main-button-span.jpg) left top no-repeat; padding:0 0 0 7px; }
<div id="main">
<div class="shell">
<div class="box">
<h2 style="color:#565656;">Latest News</h2>
<div class="entry">
<div class="news">
newsstring;
</div>
</div>
</div>
<div class="box">
</div>
</div>
</div>
<!-- End of Main -->
<!-- Footer -->
<div id="footer">
<div class="shell">
<div class="footer-navigation">
<ul>
<li>Home</li>
<li>About</li>
<li>Gallery</li>
<li>Location</li>
<li class="last">Contact</li>
</ul>
</div>
<div class="container">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="height:10px; width:1000px">
<tbody>
<tr>
<td style="height:75px; text-align:center; vertical-align:middle; width:560px">
<p><img alt="Seertech Solutions Pvt. Ltd" src="./css/images/seertechbanner.jpg" style="height:55px; width:660px" /></p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Keep in mind that there are more solutions. You could use flex-box approach, you could use display:inline-block approach, you coul even use grid approach. It all depends on what you want to achieve and what browsers you want to support.
If you have floated children (.box), your parent block don't know about that until you tell him. Just add to parent block (.shell) style overflow :hidden.
#main .shell { overflow :hidden; }

Google homepage bottom elements not fixed when hovering buttons

my problem
I just want help on how to make the footer and 'Google in different languages' fixed when I am hovering over the buttons.
I am trying to build it on my own (without referring to google homepage code in chrome dev tools), so I am unaware of what they did so as to fix the position of those two elements.
Here's my code:
<!DOCtype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css_stylesheets/stylesheet3.css"/>
<title>Google</title>
</head>
<body>
<div>
<header class="start">
<ul>
<li>Gmail</li>
<li>Images</li>
<li class="button">Sign in</li>
</ul>
</header>
<h1>
<img src="../Images/googlelogo.png" alt="Google logo"/>
<span>India</span>
</h1>
<form>
<input type="text"/><br>
<input type="submit" value="Google Search" id="text" name="search"/>
<input type="submit" value="I'm Feeling Lucky" name="search2"/>
</form>
<p>
Google.co.in offered in: HindiBanglaMalayalamMarathi
</p>
<footer>
<nav class="left">
<ul>
<li>Advertising</li>
<li>Business</li>
<li>About</li>
</ul>
</nav>
<nav class="right">
<ul>
<li>Privacy</li>
<li>Terms</li>
<li>Settings</li>
<li>UseGoogle.com</li>
</ul>
</nav>
</footer>
</div>
</body>
</html>
My CSS stylesheet:
*
{
padding:0px;
margin: 0px;
}
body
{
font-family:Arial,sans-serif;
}
div:first-child
{
font-size:25px;
margin:auto;
text-align:center;
padding-top:0px;
}
div header ul
{
margin-right:0px;
text-align:right;
font-size: 17px;
}
body div header.start
{
padding-top:0px;
}
h1
{
display:inline-block;
font-size:20px;
}
h1 span
{
position:relative;
right: 63px;
bottom: 5px;
color:rgb(51,187,232);
font-size:small;
font-family: "Arial", sans-serif;
}
li.button a
{
display:inline-block;
outline:none;
background-color:rgb(10,125,247);
padding:9px;
border:solid 1px;
border-radius: 4px;
font-weight: bold;
color:#F5F5F5;
}
li.button a:hover
{
text-decoration:none;
outline:grey 3px;
box-shadow: inset 0 0 0px 1px #27496d;
}
li.button a:active
{
background-color:rgb(11,95,191);
border:inset 1px #C7C7C7;
}
a
{
text-decoration: none;
word-spacing:5px;
font-size: 15px;
color:grey;
}
a:hover
{
text-decoration:underline;
}
a::after
{
content: " ";
text-decoration: none;
}
input[type="text"]
{
margin:auto;
max-width:500px;
width:40%;
padding:10px;
}
input[type="text"]:visited
{
outline:blue;
}
input[type="submit"]
{
color:#727578;
border:solid 0px;
background-color:#E3E6E8;
font-weight:bold;
padding:10px;
margin: 30px 5px;
margin-bottom:0px;
}
input[type="submit"]:hover
{
border:ridge 2px;
color:black;
background-color:#f0f0f0;
}
input[type="submit"]:active
{
outline:blue;
}
p
{
margin:0px;
padding:0px;
font-size:14px;
position:relative;
top:15px;
}
p a::after
{
content: " ";
text-decoration: none;
}
p a:link
{
color: blue;
}
ul li
{
list-style-type: none;
display:inline;
word-spacing: 10px;
}
nav.left ul li
{
padding-top:2px;
position:relative;
right:590px;
top:50px;
}
nav.right ul li
{
position:relative;
left:500px;
top:0px;
}
footer nav.right ul
{
display:block;
background-color:#e3e3e3;
padding-top:20px;
margin-bottom:0px;
}
Let me tell you that I am very new to CSS3 elements. But I am pretty much familiar with most of the CSS ones.
I repeat, I don't need a complete debugging on this (unless required that is). Please help me on that issue (the text in bold at the beginning of this topic).
Your problem is input[type="submit"]:hover changing border-width from 0px to 2px, so total height and width of buttons increasing and moving below content for 4px.
Your solution is to change
input[type="submit"] {
...
border: solid 0px;
...
}
to
input[type="submit"] {
...
border: transparent solid 2px;
...
}

How to spread list item content evenly and centered in HTML header?

I currently have a Header in my HTML which is a Unordered List with List Items display = inline. What I am try to accomplish is to spread each of the 5 items into an equaled space (20% Width for each) and step them centered in their respective spaces. I was able to accomplish this with a lot of ease on the Footer, but instead of List Items, I used Divs for each of the Options. Can anyone help me do the same with list? I can redo it as Divs, but I'd like to at least know how to make the list work.
How it should be
html, body {
margin:0;
padding:0;
height:100%;
}
a:link {
text-decoration:none;
}
#page {
position:relative;
background:#E9EAEE;
min-height:100%;
}
#header {
position:fixed;
left:0px;
top:0px;
z-index:1;
width:100%;
background-color:#3f5c99;
padding-top:10px;
}
#header .holder {
width:100%;
float:left;
}
#header a {
color:#ffffff;
font-size:11px;
font-weight: bold;
padding:0px 10px 0 0;
text-transform:uppercase;
}
#header li {
display:inline;
margin-left:-10px;
padding:0 4px 0 6px;
border-left: 1px solid #2F477A;
}
.logo {
border-radius:2px;
}
<body>
<div id="page">
<div id="header">
<div class="holder">
<ul>
<li style="border-left:0px;"><img class="logo" src="../img/logo.png"/></li>
<li>Comics</li>
<li><img src="../img/friendOff.png"/></li>
<li><img src="../img/mailChatOff.png"/></li>
<li><img src="../img/globeOff.png"/></li>
</ul>
</div>
</div>
...
</div>
</body>
I hope I was able to illustrate what I am trying to accomplish, but if it is still unclear please let me know. Thanks in advance for any help.
You can try like this ,I hope it will helps you.
html, body {
margin:0;
padding:0;
height:100%;
}
a:link {
text-decoration:none;
}
#page {
position:relative;
background:#E9EAEE;
min-height:100%;
}
#header {
position:fixed;
left:0px;
top:0px;
z-index:1;
width:100%;
background-color:#3f5c99;
}
#header .holder {
width:100%;
float:left;
}
#header ul {
display: table;
margin: 0;
padding: 0;
width: 100%;
}
#header a {
color: #ffffff;
display: inline-block;
font-size: 11px;
font-weight: bold;
text-transform: uppercase;
}
#header li {
display: table-cell;
padding: 5px 0;
position: relative;
text-align: center;
vertical-align: middle;
width: 20%;
}
#header li:after {
border-left: 1px solid #2f477a;
content: "";
height: 20px;
position: absolute;
right: 0;
top: 8px;
}
.logo {
border-radius:2px;
}
<body>
<div id="page">
<div id="header">
<div class="holder">
<ul>
<li style="border-left:0px;"><img class="logo" src="../img/logo.png"/></li>
<li>Comics</li>
<li><img src="../img/friendOff.png"/></li>
<li><img src="../img/mailChatOff.png"/></li>
<li><img src="../img/globeOff.png"/></li>
</ul>
</div>
</div>
...
</div>
</body>
ul {
display: flex;
}
#header li {
...
flex: 1;
display: flex;
align-items: center;
justify-content: center;
...
}
https://jsfiddle.net/234zzgn7/
Add this css. Ofcourse this is using flexbox which is something that I found to be extremely awesome. But you should investigate whether your users support it or not.
http://caniuse.com/#search=flexbox
Here try this. Changes are on #header li and #header a
html, body {
margin:0;
padding:0;
height:100%;
}
a:link {
text-decoration:none;
}
#page {
position:relative;
background:#E9EAEE;
min-height:100%;
}
#header {
position:fixed;
left:0px;
top:0px;
z-index:1;
width:100%;
background-color:#3f5c99;
padding-top:10px;
}
#header .holder {
width:100%;
float:left;
}
#header a {
color:#ffffff;
font-size:11px;
font-weight: bold;
padding:0px 10px 0 0;
text-transform:uppercase;
display:block;
width:100%;
box-sizing:border-box;
}
#header li {
display:inline-block;
box-sizing:border-box;
width:20%;
margin-left:-10px;
padding:0 4px 0 6px;
border-left: 1px solid #2F477A;
}
.logo {
border-radius:2px;
}
<body>
<div id="page">
<div id="header">
<div class="holder">
<ul>
<li style="border-left:0px;"><img class="logo" src="../img/logo.png"/></li>
<li>Comics</li>
<li><img src="../img/friendOff.png"/></li>
<li><img src="../img/mailChatOff.png"/></li>
<li><img src="../img/globeOff.png"/></li>
</ul>
</div>
</div>
...
</div>
</body>

why are my DIVs overlapping

Can someone please tell me why my 'header' div and 'pageInnerWrap' div are overlapping...been messing about with position absolute but cant get it...any help appreciated...ta
<div id="pageWrap">
<div id="pageInnerWrap" class="push">
<div id="header" class="push">
<div class="inner-wrap">
<a id="A2" href="Home.aspx"><img src="/images/logo_new.png" alt="Azi Map" /></a>
<div style="position:relative;float:right">
<%--Login Stuff--%>
<div class="loginDisplay" style="width:33%">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<AnonymousTemplate>
<img src="/images/btn_login.png" alt="Login" />
Login |
<a id="A4" href="~/Account/Register.aspx" runat="server" title="Sign up for your 30 days free trial">Free Trial</a>
</AnonymousTemplate>
<LoggedInTemplate>
Welcome <span class="bold"><asp:Label id="UserLogonID" runat="server"></asp:Label></span>,
<br />
[<asp:HyperLink ID="hlChangePassword" runat="server" NavigateUrl="~/Account/ChangePassword.aspx">Change Password</asp:HyperLink>]
[<asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/Home.aspx"/>]
<br />
</LoggedInTemplate>
</asp:LoginView>
<p style="text-align:right">
<asp:Label ID="lblFreeTrialDays" runat="server" Text=""></asp:Label>
</p>
</div>
</div>
<ul id="nav">
<li><img src="/images/btn_layers.png" alt="Layers" />Layers</li>
<li><img src="/images/btn_maps.png" alt="Layers"/>Maps</li>
<li><img src="/images/btn_admin.png" alt="Layers"/>Admin</li>
</ul>
<div id="mobile-btn">
<img src="imgs/menu_btn.png" alt="Menu Button" />
</div>
</div>
</div><%--header--%>
<div style=" margin: 0 auto; width: 2000px; height: 1200px">
<div id="mainContent" class="main" style="background:white;">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
<div style= "visibility:hidden;>
<div id="AlertDiv" class="AlertStyle">
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/loading.GIF"/>
</div>
</div>
</div>
</div>
</div>
<div id="mobile-nav-items">
<ul>
</ul>
</div>
</div>
CSS
* {
box-sizing: border-box;
}
html, body, div {
border: 0 none;
margin: 0;
padding: 0;
}
body { padding-top:150px; }
#pageWrap { position: relative; }
#pageInnerWrap { position: relative; }
div#header { background:#1E4964; color:#fff; font:14px/1.5em Arial, sans-serif; font-weight:600; position:fixed; width:100%; top:0; }
div#header .inner-wrap { max-width:1900px; margin:0 auto; width:95%; padding:0 2.5%; }
div#header a { color:#fff; position:relative; text-decoration: none; }
div#header a:active { top:1px; }
header #page-header-top { background:#000; }
header #page-header-top .inner-wrap { padding-top:10px; padding-bottom:10px; height:40px; text-align:right; overflow: hidden; }
header #page-header-top .inner-wrap a { background:#153447; }
header #page-header-top img { position: relative; top:4px; left:-4px; }
header #page-header-top a:hover { text-decoration: underline; }
header #mobile-btn { display:none; }
header a#logo { float:left; margin:38px 0; }
div#heade ul#nav { float:right; margin:0; }
div#heade ul#nav li { display:inline-block; text-align:center; }
div#heade ul#nav li a { padding:20px 30px; display:inline-block; }
div#heade ul#nav li a:hover { background:#185070; }
div#heade ul#nav li a#active { background:#153447; }
div#heade ul#nav li a img { margin:0 auto 20px; display:block; }
header .clear { clear:both; }
#mobile-nav-items { display:none; }
#mobile-btn { display:none; float:right; margin:35px 0; padding:10px 10px 5px; cursor: pointer; position: relative; }
#mobile-btn:active { top: 1px; }
#media only screen and (max-width : 1200px) {
header ul#nav li a { padding-left:20px; padding-right:20px; }
}
#media only screen and (max-width : 950px) {
header #mobile-btn { display:block; }
header #mobile-btn:hover { background:#153447; }
header #mobile-btn.menu-open { background:#153447; }
header #mobile-btn img { width:20px; }
#mobile-nav-items {
display:block;
}
ul#nav { display: none; }
}
/* change on scroll */
div#header,
div#header * {
-webkit-transition: all 0.3s ease-in;
-moz-transition: all 0.3s ease-in;
-o-transition: all 0.3s ease-in;
transition: all 0.3s ease-in;
}
header.scrolled #page-header-top .inner-wrap { height:0; padding-top:0; padding-bottom:0; }
header.scrolled a#logo { margin:12px 0 5px; }
header.scrolled ul#nav li a img { height:0; margin:0; }
header.scrolled #mobile-btn { margin:10px 0 3
px; }
Not surprised you have a problem with this code, get your indentation right, I think you're missing a closing </div> and there's a missing quotation mark:
<div style= "visibility:hidden;>
I tried to clean it up, but gave up, only you know which part should be where.
For example put siblings on the same tabulation level:
<div id="header" class="push">
<div class="inner-wrap">
<a id="A2" href="Home.aspx"><img src="/images/logo_new.png" alt="Azi Map" /></a>
<div style="position:relative;float:right">
...
</div>
...
<div />
</div>
</div>
Also on SO, you need 4 spaces or a tab before your code block, but not more, just look at your question, half of the code is unnecessary leading whitespace.

centering a transparent menu

I am trying to make my transparent menu appear centered, but whatever method I dig up from the internet, nothing seems to do the trick.
I would really love if someone could look through this code, and give me a hand. :)
The HTML-part:
<div id="container">
<div id="menu">
<span class="bg"></span>
<ul>
<li>PRINT</li>
<li>TV</li>
<li>OTHER</li>
<li>RESUME</li>
</ul>
</div>
The CSS part:
#container
{
display: inline-block;
*display: inline;
zoom: 1;
padding: 10px 0 0 0
overflow:hidden;
font-family:arial;
height:400px;
}
#menu
{
float: left; // **WHENEVER I CHANGE THIS FLOAT, THE MENU-BACKGROUND DISAPPEARS?!**
position: relative;
display:inline;
border:2px solid #000;
border-top:0;
border-radius:0 0 10px 10px;
}
#menu .bg
{
position:absolute;
width:100%;
height:100%;
background:#000;
opacity:0.5;
filter:alpha(opacity=50);
left:0;
top:0;
}
#menu li
{
float:left;
}
#menu a
{
text-decoration:none;
position:relative;
padding:8px 13px;
color:white;
font-weight:bold;
z-index:2;
float:left;
}
#menu a:hover
{
color:#999;
}
You can do it by updating #menu to:
#menu {
position: absolute;
border:2px solid #000;
border-top:0;
border-radius:0 0 10px 10px;
left: 50%;
margin-left: -152px;
width: 305px;
}
JSFiddle
The reason that your menu is not centering, is because you do not have a defined width for either the menu or the container. If you had a defined width, then you would be able to use:
margin: 0 auto;
I'm not sure yet why your float starts messing up your background colors, however I did notice you missed a semicolon at the end of one of your style properties
#container
{
padding: 10px 0 0 0
...
}
should be
#container
{
padding: 10px 0 0 0;
...
}
Another option:
EDITED CSS:
#container
{
display: inline-block;
*display: inline;
zoom: 1;
padding: 10px 0 0 0
overflow:hidden;
font-family:arial;
height:400px;
}
#menu
{
float: left; // **WHENEVER I CHANGE THIS FLOAT, THE MENU-BACKGROUND DISAPPEARS?!**
position: relative;
display:inline;
}
#menu .bg
{
position:absolute;
width:100%;
height:100%;
background:#000;
opacity:0.5;
filter:alpha(opacity=50);
left:0;
top:0;
}
#menu ul { <===Added this definition and moved the border here as well
clear:left;
float:left;
list-style:none;
margin:0;
padding:0;
position:relative;
left:50%;
text-align:center;
border:2px solid #000;
border-top:0;
border-radius:0 0 10px 10px;
}
#menu li
{
float:left;
}
#menu a
{
text-decoration:none;
position:relative;
padding:8px 13px;
color:white;
font-weight:bold;
z-index:2;
float:left;
}
#menu a:hover
{
color:#999;
}​
EDITED HTML (closed a div tag)
<div id="container">
<div id="menu">
<span class="bg"></span>
<ul>
<li>PRINT</li>
<li>TV</li>
<li>OTHER</li>
<li>RESUME</li>
</ul>
</div>
</div>​
And here's the FIDDLE
Centering floats is difficult. Here's one method:
<style type="text/css">
#container
{
font-family:arial;
height:400px;
border: red;
position: relative;
}
#menu
{
position:relative;
left:-50%;
float:right;
}
ul
{
position:relative;
left:50%;
background: rgba(0, 0, 0, 0.5);
overflow: hidden;
}
li{
display:block;
float:left;
padding: 8px 13px;
}
a {text-decoration:none;}
</style>
<div id="container">
<div id="menu">
<ul>
<li>PRINT</li>
<li>TV</li>
<li>OTHER</li>
<li>RESUME</li>
</ul>
</div>
</div>
Source: http://browse-tutorials.com/snippet/center-floats-css
Fiddle: http://jsfiddle.net/yucHM/2/