Jump to content


CSS Questions


10 replies to this topic

#1 NightWolf

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 27 May 2007 - 09:20 PM

I'm still learning CSS and having some problems.

1) On the site I am designing I would like the footer to stay at bottom of the window and when content is bigger than window I would it to move accordingly.

2) My divs are 1px off balance to the left in IE how would I fix this?
The banner, navbar, and footer bar is that way when viewing this page in IE http://inevmaps.hl2f...om/v9/index.php

3) How would I add padding to a div which has a background image without the background image spilling out of the div? An example where I want to do this is adding a 5px all around padding to my #footer div.

Of course here is the CSS and the html:


CSS:

@charset "utf-8";
/* CSS Document */

body{

margin:0px;
background: #526d7b url(images/bg.gif) repeat-y scroll top center; 
text-align:center;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
}

#main_container{
width:850px;
height:auto;
margin:auto;
}

#banner{
background-image:url(images/banner.jpg);
width:850px;
height:150px;
}

#nav_bar{
width:850px;
height:32px;
}

#footer
{
	background: url(images/footer_bar.gif) scroll bottom center;
	height:32px;
	width:850px;
	color:#666666;
}

#content_container{
width:850px;
height:auto;
}

/*News Code Begin*/


HTML:
(Please excuse the ugly auto java code that dreamweaver made for my rollover images)

<!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" />
<title>Untitled Document</title>
<link href="inevmaps.css" rel="stylesheet" type="text/css" />

&lt;script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>

</head>

<body onload="MM_preloadImages('images/home_over.gif','images/maps_over.gif','images/media_over.gif','images/forums_over.gif','images/about_over.gif','images/contact_over.gif')">

<div id="main_container">

	<div id="banner"></div>

		  <div id="nav_bar">
<a href="http://inevmaps.hl2files.com/index.php" onmouseout="MM_swapImgRestore()" onmouseover=			 							"MM_swapImage('Home','','images/home_over.gif',1)"><img src="images/home.gif" name="Home" width="140" height="32" border="0" id="Home" 	/></a><a href="http://inevmaps.hl2files.com/maps.php" onmouseout="MM_swapImgRestore()" onmouseover=		"MM_swapImage('Maps','','images/maps_over.gif',1)"><img src="images/maps.gif" name="Maps" width="142" height="32" border="0" id="Maps" 		/></a><a href="http://inevmaps.hl2files.com/media/index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Media','','images/media_over.gif',1)"><img src="images/media.gif" name="Media" width="143" height="32" border="0" id="Media" /></a><a href="http://inevmaps.hl2files.com/forums/" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Forums','','images/forums_over.gif',1)"><img src="images/forums.gif" name="Forums" width="143" height="32" border="0" id="Forums" /></a><a href="http://inevmaps.hl2files.com/about.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('About','','images/about_over.gif',1)"><img src="images/about.gif" name="About" width="142" height="32" border="0" id="About" /></a><a href="http://inevmaps.hl2files.com/contact.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Contact','','images/contact_over.gif',1)"><img src="images/contact.gif" name="Contact" width="140" height="32" border="0" id="Contact" /></a>		
  </div>



		 <div id="footer"><br />
   		 Copyright © 2007 Inevitable Maps - Designed by NightWolf - Best if viewed in a 1024*768 resolution or higher</div>
</div>

</div>

</body>
</html>

Here is my site useing the code above http://inevmaps.hl2f...om/v9/index.php

#2 _*Creative Insanity_*

  • Guests

Posted 27 May 2007 - 10:38 PM

Number one has already been had a lengthy talk on here.
But anyway here is the answer to 1.

html, body{

margin:0px;
background: #526d7b url(images/bg.gif) repeat-y scroll top center;
text-align:center;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
height:100%
}

#main_container{
width:850px;
height:100%;
margin:auto;
}

#banner{
background-image:url(images/banner.jpg);
width:850px;
height:150px;
}

#nav_bar{
width:850px;
height:32px;
}

#footer
{
	background: url(images/footer_bar.gif) scroll bottom center;
	height:32px;
	width:850px;
	color:#666666;
   magin: -32px auto 0;
}

#content_container{
width:850px;
height:auto;
}

/*News Code Begin*/

Number 2.
IE just plain sucks, let someone else get this:

Number 3.
Do something like this.
Just assume the padding is for the content div.
#content P(
  padding:10px;
}
Now place all the content in a paragraph. That will give an all around 10px padding.
Remember that paddings is inside and margin is outside.

#3 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 27 May 2007 - 11:27 PM

Well, you got the answer to number one half right. If you read my post in that topic, you would know the footer won't move with the content that way.

1. My site does have a footer that stays at the bottom and moves with content (albeit a little flawed at the moment). Basically, it uses floats and a little other fancy work to stay down.

2. I believe that is a standard bug called the "1px jump" or something like that. But of course, i could be confusing it with the 3px one... Google it...

3. Since i don't have a picture of what you mean when you say "spilling out" i will offer three suggestions (take your pick, or mix and match):
#footer {
	overflow:hidden;			 /* 1 */
	margin: 10px;				/* 2 */
	background-repeat:no-repeat; /* 3 */
}

Edited by rc69, 28 May 2007 - 12:15 AM.


#4 NightWolf

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 28 May 2007 - 01:11 AM

1) Unfortunately this one didnt work <3

2) Im going to keep searching for this one but didnt find anything yet

3) Here is what I mean by spilling out

Posted Image

Edited by NightWolf, 30 May 2007 - 03:38 PM.


#5 tomos

    Young Padawan

  • Members
  • Pip
  • 58 posts

Posted 28 May 2007 - 08:49 AM

The footer fits in the container with opera.

Would adding clear:both; to the footer help?

#6 NightWolf

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 28 May 2007 - 09:07 AM

View Posttomos, on May 28 2007, 09:49 AM, said:

The footer fits in the container with opera.

Would adding clear:both; to the footer help?

That didn't work also I haven't uploaded the padding version of the footer to the site yet.

#7 NightWolf

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 29 May 2007 - 01:37 PM

Now I am doing the design a little differently and need some help.

First I have my div right_container floated right which is in the content_container the problem is since its floated right for some reason the content_container doesn't expand.

Next in the links area where is says "Links will go here." its 1px off on the right. http://inevmaps.hl2f...om/v9/index.php

I tried to fix it but have had no luck.

Here is my new CSS:

@charset "utf-8";
/* CSS Document */

body{
margin:0;
text-align:center;
background-color:#536e7c;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
}

#main_container{
width:900px;
height:auto;
background-image:url(images/bg.gif);
background-repeat:repeat-y;
margin-left: auto;
margin-right: auto;
text-align:center;
}

#banner{
background-image:url(images/banner.jpg);
width:850px;
height:150px;
margin:auto;
}

#navbar{
height:32px;
width:850px;
margin:auto;
}

#footer{
background-image:url(images/footer_bar.gif);
width:900px;
height:50px;
}

#content_container{
width:850px;
height:auto;
margin:auto;
text-align:left;
}

#right_container{
width:150px;
height:auto;
float:right;
}

#links{
height:auto;
width:150px;
background:#CCCCCC;
border:solid #c2c2c2;
border-width:0px 1px 0px 1px;
}

#links_topcap{
background-image:url(images/links_top_cap.gif);
width:150px;
height:25px;
}

#sidebar_bottomcaps{
background-image:url(images/small_bottom_cap.gif);
height:25px;
width:150px;
}

Here is my new html:

<!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" />
<title>Untitled Document</title>
<link href="inevmaps.css" rel="stylesheet" type="text/css" />
&lt;script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>

<body onload="MM_preloadImages('images/home_over.gif','images/maps_over.gif','images/media_over.gif','images/forums_over.gif','images/about_over.gif','images/contact_over.gif')">

<div id="main_container">

  <div id="banner"></div>
	
		<div id="navbar">
		
		  <a href="http://inevmaps.hl2files.com/index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','images/home_over.gif',1)"><img src="images/home.gif" name="Home" width="140" height="32" border="0" id="Home" /></a><a href="http://inevmaps.hl2files.com/maps.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Maps','','images/maps_over.gif',1)"><img src="images/maps.gif" name="Maps" width="142" height="32" border="0" id="Maps" /></a><a href="http://inevmaps.hl2files.com/media/index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Media','','images/media_over.gif',1)"><img src="images/media.gif" name="Media" width="143" height="32" border="0" id="Media" /></a><a href="http://inevmaps.hl2files.com/forums/" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Forums','','images/forums_over.gif',1)"><img src="images/forums.gif" name="Forums" width="143" height="32" border="0" id="Forums" /></a><a href="http://inevmaps.hl2files.com/about.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('About','','images/about_over.gif',1)"><img src="images/about.gif" name="About" width="142" height="32" border="0" id="About" /></a><a href="http://inevmaps.hl2files.com/contact.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Contact','','images/contact_over.gif',1)"><img src="images/contact.gif" name="Contact" width="140" height="32" border="0" id="Contact" /></a></div>
	
				  <div id="content_container">
				  <div id="right_container">
				  <div id="links_topcap"></div>
				  <div id="links">Links will go here.</div>
				  <div id="sidebar_bottomcaps"></div>
				  </div>
				  </div>
	
			<div id="footer"></div>
</div>

</body>
</html>

Edited by NightWolf, 29 May 2007 - 08:59 PM.


#8 NightWolf

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 29 May 2007 - 04:51 PM

Anybody? ;)

#9 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 29 May 2007 - 05:30 PM

Bump master ;) 3 hours after your last reply..?

Either way..

1. Add a clearing div below all content

				  <div id="right_container">
				  <div id="links_topcap"></div>
				  <div id="links">Links will go here.</div>
				  <div id="sidebar_bottomcaps"></div>
				  </div>
				  <div style="clear:both;"></div>
				  </div>

2. It's most likely your border expanding the div with a pixel on both sides. Simply reduce the width by 2 pixels, or just remove the border completely. Whats the point of having a border with the same colour as your background color after all?

#10 NightWolf

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 29 May 2007 - 07:51 PM

Thank you so much! ;) It works perfectly!

Sorry about the 3hr bump lol I was very eager to get it working correctly. ^^

Edit: I found out the margins were causing my other problem, thanks for everyones help again I will be sure to thank you when I out up the new site.

Edited by NightWolf, 01 June 2007 - 05:39 AM.


#11 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 01 June 2007 - 12:22 AM

Please stop bumping your post. It hasen't left the top 5 yet, people can still see it.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users