School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,355 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,946 people online right now. Registration is fast and FREE... Join Now!




Float makes my background disappear...!

 

Float makes my background disappear...!, Whenever I try to float: left on the li tag the background disappears

MacAnimeGirl

29 Dec, 2008 - 02:04 PM
Post #1

D.I.C Regular
Group Icon

Joined: 30 Sep, 2008
Posts: 275



Thanked: 6 times
My Contributions
Here's the code:

css
body
{
background-color: Silver;
}

#contentMain
{
background-color: Transparent;
}

#divLogoNem, #divCompanyNews, #divLogin, #divNavigation, #divContentMain, #divLegalities
{
width: 790px;
margin: auto;
}

.bg
{
width: 800px;
margin-left: auto;
margin-right: auto;
}

#divBg
{
background-image: url(../images/back.gif);
background-position: center;
background-repeat: repeat-y;
padding: 1px 0 1px 0;
}

#mainMenu
{
padding: 0;
background-image:url(../images/menuBack.gif);
list-style-type: none;

background-repeat:repeat-x;
}

li
{
float: left;
}


Here's the page...
HTML
<%@ Master Language="VB" CodeFile="Site.master.vb" Inherits="Site" %>
<!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 runat="server">
<link rel="stylesheet" type="text/css" href="css/main.css" />
<title>Untitled</title>
</head>
<body>
<form id="masterForm" runat="server">
<div id="divTopBg" class="bg">
<img src="images/top.gif" id="topbg" alt=""/>
</div>
<div id="divBg">
<div id="divLogoNem" class="back">
</div>

<div id="divCompanyNews" class="back">
</div>

<div id="divLogin" class="back">
</div>

<div id ="divNavigation" class="back">
<ul id="mainMenu">
<li>Home</li>
<li>Products</li>
<li>Services</li>
<li>News & Events</li>
<li>Inquiry / Feedback</li>
<li>Technical Support</li>
<li>Company Information</li>
<li>Careers</li>
</ul>

<ul id="prodMenu" runat="server">
<li>MICS</li>
<li>Shift Manager</li>
<li>NETS</li>
</ul>
<ul id="servMenu" runat="server">
<li>Billing</li>
</ul>
<ul id="newsMenu" runat="server">
<li>Press Release</li>
<li>User Conferences & Forums</li>
<li>Trade Shows</li>
</ul>
<ul id="suppMenu" runat="server">
<li>Request Form</li>
<li>Bomgar</li>
</ul>
<ul id="compInfoMenu" runat="server">
<li>History</li>
<li>Employees</li>
<li>Testimonials</li>
<li>Contact Us</li>
</ul>
</div>

<div id="divContentMain" class="back">
<asp:contentplaceholder id="contentMain" runat="server">
</asp:contentplaceholder>
</div>

<div id="divLegalities" class="back">
</div>

</div>

<div id="divBottomBg" class="bg">
<img src="images/bottom.gif" id="bottombg" alt=""/>
</div>

</form>
</body>
</html>


And here's the code behind the page...
vb
Partial Class Site
Inherits System.Web.UI.MasterPage

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
prodMenu.Visible = False
servMenu.Visible = False
newsMenu.Visible = False
suppMenu.Visible = False
compInfoMenu.Visible = False
End Sub
End Class


Now, my problem. I have a background that is basically a 800x25 pixel strip. it's with the ends have a blue line down the side. I have it repeat y so it will make the expandable.

I'm putting the navigation system in. It's an unordered list so I need to float: left the list items so they'll be in a line. I have a gradient background light blue in the middle dark blue at the top and bottom. What I want is to have the line background behind it.

But whenever I put in the float the background disappears... When the float is taken out... it reappears? Any help please?

User is offlineProfile CardPM
+Quote Post


MacAnimeGirl

RE: Float Makes My Background Disappear...!

29 Dec, 2008 - 02:11 PM
Post #2

D.I.C Regular
Group Icon

Joined: 30 Sep, 2008
Posts: 275



Thanked: 6 times
My Contributions
Okay, figured out it was because of a browser issue. I just needed to add overflow: hidden to my #divBg in my css!

Hope this might help someone who is having the same problem!!
User is offlineProfile CardPM
+Quote Post

nikitaNYC

RE: Float Makes My Background Disappear...!

12 Jun, 2009 - 01:45 PM
Post #3

New D.I.C Head
*

Joined: 12 Jun, 2009
Posts: 1

Thank you so much. I was having the same problem, but overflow:hidden solved it!

User is offlineProfile CardPM
+Quote Post

rachelalbert

RE: Float Makes My Background Disappear...!

23 Jun, 2009 - 08:26 PM
Post #4

New D.I.C Head
*

Joined: 11 Jun, 2009
Posts: 10

Thanks, you helped me too. My background color was disappearing when I floated elements within my div. Used overflow:hidden, bingo, problem solved.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 07:28PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month