Jump to content

background color playing up?


wright67uk

Recommended Posts

Im trying to get everything in and within my wrapper div to have a blue background.

Unfortunately .list exposes a white background where its margins are.

see (www.1pw.co.uk/b.php)

Any way around this?

 

You can preview this file in IE, however firefox seems to hate me and my site.  More work to do I guess.

 

a.css

@charset "utf-8";
body {
color:#06F;
}

h1
{
color:#FFF;
font-size:18px;
padding-bottom:0px;
margin-bottom:3px
}
input
{
color: #781351;
background: #B9E7FF;
border: 1px solid #06C
}
.submit input
{
color: #000;
background: #ffa20f;
border: 2px outset #d7b9c9
} 


form#add {     
  background-color: #cccccc;     
  color: #F00;     
  border: 1px solid #999999;     
  font-family: Verdana, Arial, Helvetica, sans-serif;     
  font-size: 18px;     
  text-align: right;    
}  
.list {
width:230px;
margin-left:20px;
color:#FFF;
height:auto;
float:left;
background-color:#06F
}
#listhold {
width:1000px;
height:auto;
margin-left:auto;
margin-right:auto;
margin-top:20px;
background-color:#06F
}
a:link {
color: #FFF;
text-decoration:none
}
a:visited {
color: #FFF;
text-decoration:none
}
a:hover {
color: #FFF;
text-decoration:none
}
a:active {
color: #FFF;
text-decoration:none
}
#wrapper {
background-color:#06f;
height:auto;
width:auto
}

 


<!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" />


<!--ADD TAKEAWAYS TYPE AND SOME SUBTYPES -->





<?php 
  include($_SERVER['DOCUMENT_ROOT'].'/include/db.php');
?>
<title>Untitled Document</title>
<style type="text/css">
<!--
-->
</style>
<link href="a.css" rel="stylesheet" type="text/css" />
<link href="newbusiness.css" rel="stylesheet" type="text/css" />
</head><body>

<div id="banner">
<div id="bannerleft"></div>
<div id="logo"></div>
<div id="bannerright"><div id="navbar" title="">	 
						 <div id="b1"><p class="centre"><a href="index.html">Directory</a></p></div>
    					 	 <div id="b2"><p class="centre"><a href="business.html">Add Your Business</a></p></div>
   						 	 <div id="b3"><p class="centre"><a href="contact.html">Contact Us</a></p></div>
    	</div><!-- end of navbar-->
</div><!--end of bannerright-->
</div><!-- end of banner-->
<div id="wrapper">
<div id="listhold">

<!------------------------------------------------------------------------------------------------------------------------------------------------------>

<div class="list"><h1>Places To Stay</h1>
<?php
$title ="TITLE GOES HERE";
$query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Accommodation' AND confirmed ='Yes' ORDER BY name");
echo mysql_error();
while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0];
$i = -1;
foreach($nt as $value)
{$i++;
$FileName = str_replace(' ','_',$nt[$i]) . ".php";
$FileUsed = str_replace('_',' ',$nt[$i]);
echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>"  . $nt[$i] . "</a>" . "<br/>";
$FileHandle = fopen($FileName, 'w') or die("cant open file");
$pageContents = file_get_contents("header.php");
fwrite($FileHandle,"$pageContents");}
fclose($FileHandle);
?>
</div>

<!------------------------------------------------------------------------------------------------------------------------------------------------------>

<div class="list"><h1>Eating Out</h1>
<?php
$nt = array();
$title ="TITLE GOES HERE";
$query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Restaurant' AND confirmed ='Yes' ORDER BY name");
echo mysql_error();
while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0];
$i = -1;
foreach($nt as $value)
{$i++;
$FileName = str_replace(' ','_',$nt[$i]) . ".php";
$FileUsed = str_replace('_',' ',$nt[$i]);
echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>"  . $nt[$i] . "</a>" . "<br/>";
$FileHandle = fopen($FileName, 'w') or die("cant open file");
$pageContents = file_get_contents("header.php");
fwrite($FileHandle,"$pageContents");}
fclose($FileHandle);
?>
</div>

<!------------------------------------------------------------------------------------------------------------------------------------------------------>

<div class="list"><h1>Eating In</h1>
<?php
$nt = array();
$title ="TITLE GOES HERE";
$query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Takeaways' AND confirmed ='Yes' ORDER BY name");
echo mysql_error();
while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0];
$i = -1;
foreach($nt as $value)
{$i++;
$FileName = str_replace(' ','_',$nt[$i]) . ".php";
$FileUsed = str_replace('_',' ',$nt[$i]);
echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>"  . $nt[$i] . "</a>" . "<br/>";
$FileHandle = fopen($FileName, 'w') or die("cant open file");
$pageContents = file_get_contents("header.php");
fwrite($FileHandle,"$pageContents");}
fclose($FileHandle);
?>	
</div>

<!------------------------------------------------------------------------------SKILLED TRADES BELOW--------------------------------------------------->

<div class="list"><h1>Skilled Trades</h1>
<?php
$nt = array();
$title ="TITLE GOES HERE";
$query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Skilled Trades' AND confirmed ='Yes' ORDER BY name");
echo mysql_error();
while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0];
$i = -1;
foreach($nt as $value)
{$i++;
$FileName = str_replace(' ','_',$nt[$i]) . ".php";
$FileUsed = str_replace('_',' ',$nt[$i]);
echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>"  . $nt[$i] . "</a>" . "<br/>";
$FileHandle = fopen($FileName, 'w') or die("cant open file");
$pageContents = file_get_contents("header.php");
fwrite($FileHandle,"$pageContents");}
fclose($FileHandle);
?>
</div>

<!------------------------------------------------------------------------------------------------------------------------------------------------------>
<div class="list"><a href="Hotels.html"></a>

</div>

<!-------------------------------------------------------------------------------                     ------------------------------------------------->
<div class="list"><a href="Electricians.html"></a><br /></div>
<div class="list"><a href="Gardeners.html"></a><br/></div>
<div class="list"><a href="More.html"></a><br/></div>
</div><!--end div list hold-->
</div><!--end of wrapper-->
</body>
</html>

 

These css properties are used mainly for other pages, but I thought Id include them here just in case.

newbusiness.css

@charset "utf-8";
#b1 {margin-right:70px; margin-left:70px; height:40px; float:left}
#b2 {margin-right:70px; height:40px; float:left}
#b3 {margin-right:70px; height:40px; float:left}
a:link {color: #FFF;text-decoration: none;}
a:visited {text-decoration: none;color: #FFF;}
a:hover {text-decoration: none;color: #CCC;}
a:active {text-decoration: none;color: #CCC;}
a.blue {color:#06F;}
p.centre {color:#FFF; margin-top:2px; text-align:center;}
#banner
{
height:80px;
width:100%;
margin-top:30px;
}
#bannerleft
{
background-color:#36F;
height:25px;
width:10%;
float:left;
margin-top:13px;
}
#logo 
{
height:80px;
width:22%;
background-image:url(i-stevenage.png);
background-repeat:no-repeat;
float:left;
}

#bannerright
{
background-color:#36F;
height:25px;
width:68%;
float:left;
margin-top:13px;
}
form
{
margin-left:405px;
margin-top:80px;
clear:both;
}
.form
{
color:#F00;
height:100px;
width:700px;
margin-left:100px;
clear:both;
}

#formtwo
{
color:#666;
height:100px;
width:700px;
margin-left:100px;
}
#results
{
margin-left:300px;
}
body
{
font-family:Tahoma, Geneva, sans-serif;
font-size:16px;
color:#252525;
}
P.form
{
color:#FF03;
margin-left:100px;
text-align:left;
clear:both;
}
P.passed
{
color:#333;
margin-left:100px;
text-align:left;
clear:both;
}
label
{
width: 6em;
float: left;
text-align: right;
margin-right: 0.5em;
display: block;
}

.submit input
{
margin-left: 4.5em;
} 
input
{
color: #333;
background: #D9FCFF;
border: 1px solid #06F;
}

.submit input
{
color: #000;
background: #ffa20f;
border: 2px outset #d7b9c9;
} 
fieldset
{
border: 1px solid #06F;
width: 20em;
}

legend
{
color: #fff;
background:#0073FF;
border: 1px solid #781351;
padding: 2px 6px;
} 

 

Many thanks

Link to comment
Share on other sites

Just quickly looking at your site, you should probably reset your floats after those lists. Inside the wrapper div, however at the bottom right before the closing </div> put in another div like:

 

<div class="clear"></div>

 

Then create a CSS rule like this:

.clear {
   clear: both;
}

 

It should reset the floats allowing the wrapper div to stretch to the full height of its children. This will then eliminate the need to supply a background-color to any of those child elements.

Link to comment
Share on other sites

or add overflow:hidden; to #wrapper.

 

so it will be like:

 

#wrapper {
    background-color: #0066FF;
    height: auto;
    overflow: hidden; /* added */
    width: auto;
}

 

i hope you also read this efficacious ...

Link to comment
Share on other sites

I did some reading on using overflow to clear floats just then, and it seems its still not foolproof but it's pretty bloody good. Apparently there are some instances with more complex layouts where it may break, but really. It's a wonderful idea, can't believe I'd never heard of that before. :) As long as a width is defined for some browsers it's flawless.

Link to comment
Share on other sites

I did some reading on using overflow to clear floats just then, and it seems its still not foolproof but it's pretty bloody good. Apparently there are some instances with more complex layouts where it may break, but really. It's a wonderful idea, can't believe I'd never heard of that before. :) As long as a width is defined for some browsers it's flawless.

Indeed! use the right tool for the right moment. this works for quite some designs.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.