Website Babble Webmaster Forums  


Go Back   Website Babble Webmaster Forums > Creating a Website > HTML, PHP, CSS, Javascript & Coding/Programming Topics

Your WB Notifications

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-09-2009, 07:32 PM
Junior Babbler
 
Join Date: Oct 2009
Location: Iowa
Posts: 10
Rooster has no reputation at Website Babble yet.
Send a message via AIM to Rooster Send a message via Yahoo to Rooster Send a message via Skype™ to Rooster
Default CSS Border Problem

I've tried everything I can think of and now I turn to everyone here for help. Here is the issue: I'm building a website that is liquid. Header is set up, navbar is setup. When I build my main content area with the borders like I want them it screws up the alignment. Like this



If I turn off the borders it does this





My widths are as follows left box is 15% center box is 70% and right box is 15% making up 100% of the main container. All padding and margins have been zeroed in the beginning of the stylesheet. I know I could do this with tables and that is my next option but I think div tags will look better and make the website easier to change around if I need to.


Thanks in advance!!
Reply With Quote
  #2 (permalink)  
Old 10-09-2009, 09:07 PM
James's Avatar
Super Moderator
 
Join Date: Dec 2007
Posts: 2,750
James is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation bars
Default a couple of thoughts

I'm not sure how your code is set up for the "box" structure you are talking about. However, it would seem that in spite of the fact that you say you zeroed out "all" the margins and padding something is not acting that way.

This may be a different approach, a bit, but personally I would use three enclosing div's and float one left and one right. This give the left and right columns the 15% values and do not designate anything for the central (main) column.

One possible problem is that, for example with ie, you can have the browser measurement being one that does not include the borders (really stupid, huh!) so that there is no room for the borders and the third section would be pushed underneath the other two because the three together are more than 100%. That may not be exactly what is happening here but something similar, probably. If you are looking at ie it may be just that.
__________________
Good Success!

Douglas County Master Gardeners
"We don't always get what we want, but we always get what we expect."
Reply With Quote
  #3 (permalink)  
Old 10-09-2009, 09:12 PM
Junior Babbler
 
Join Date: Oct 2009
Location: Iowa
Posts: 10
Rooster has no reputation at Website Babble yet.
Send a message via AIM to Rooster Send a message via Yahoo to Rooster Send a message via Skype™ to Rooster
Default

Awesome thanks for the info. I will give that a shot and see what happens. The problem is currently happening in every browser I try. The other thing I was thinking was using a table to create the columns, but, I was of the thinking that div tags would be better. Just my thoughts anyway. LOL
Reply With Quote
  #4 (permalink)  
Old 10-09-2009, 10:04 PM
James's Avatar
Super Moderator
 
Join Date: Dec 2007
Posts: 2,750
James is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation bars
Default They are better.

Div's are much better. I would not even think about going with tables. Whatever your problem you will face it in other forms over and over forever I suspect since it is so basic.

Think in terms of determination to solve the problem and learning how to do layout right in css. It is well worth the effort.

If you don't get it, I and others here will help further. We would need to get a look at the code.
__________________
Good Success!

Douglas County Master Gardeners
"We don't always get what we want, but we always get what we expect."
Reply With Quote
  #5 (permalink)  
Old 10-10-2009, 04:39 AM
Donk's Avatar
Supreme Babbler
 
Join Date: Jan 2009
Location: Kent UK
Posts: 590
Donk is an elite member of WB with 1500+ reputation pointsDonk is an elite member of WB with 1500+ reputation pointsDonk is an elite member of WB with 1500+ reputation pointsDonk is an elite member of WB with 1500+ reputation pointsDonk is an elite member of WB with 1500+ reputation pointsDonk is an elite member of WB with 1500+ reputation pointsDonk is an elite member of WB with 1500+ reputation pointsDonk is an elite member of WB with 1500+ reputation pointsDonk is an elite member of WB with 1500+ reputation pointsDonk is an elite member of WB with 1500+ reputation pointsDonk is an elite member of WB with 1500+ reputation points
Default

Hi Rooster

James is correct the "box model" for most of the current browsers is that the border is outside the box.

Say your borders are 1px and you have four across the page width the total widths of your divs would become 100% plus 4 pixels. As James says this pushes the right section under the other two.

The workaround this is to have inner divs inside your main divs. For simplicity I used class="inner" but for more control you may want to use individual ids.

HTML Code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
#left,#right{
width:15%;
background-color:#CC3300;
border-top: #FFFF00 thin solid;
border-bottom: #FFFF00 thin solid;

}
#center{
width:70%;
background-color:#333300;
border-top: #FFFF00 thin solid;
border-bottom: #FFFF00 thin solid;
}
#left,#center{
float:left;

}
#right{
float:right;
}
.inner{
border-left: #FFFF00 thin solid;
border-right: #FFFF00 thin solid;
}
</style>
</head>

<body>
<div id="left">
<div class="inner">
left
</div>
</div>
<div id="center">
<div class="inner">
center
</div>
</div>
<div id="right">
<div class="inner">
right
</div>
</div>
</body>
</html>
Regards

Bob
__________________
PHP Snippets PHP Captcha Code Resizable Html
"A website with a thousand resources starts with a single page".
"Don't fight the gator - clear the swamp"
Reply With Quote
  #6 (permalink)  
Old 10-10-2009, 10:25 AM
Junior Babbler
 
Join Date: Oct 2009
Location: Iowa
Posts: 10
Rooster has no reputation at Website Babble yet.
Send a message via AIM to Rooster Send a message via Yahoo to Rooster Send a message via Skype™ to Rooster
Default

Following your instructions I have the following.


HTML Code:
<div id="left">
 <div class="inner">
<p>&nbsp;</p>
</div></div>
<div id="center">
 <p>&nbsp;</p>
</div>
 <div id="right">
<div class="inner">
<p>&nbsp;</p>
</div></div>
Code:
#left,#right{
width:15%;
background-color:#CC3300;
border-top: #7373F7 medium solid;
border-bottom: #7373F7 medium solid;

}
#center{
width:70%;
background-color:#333300;
border-top: #7373F7 medium solid;
border-bottom: #7373F7 medium solid;
}
#left,#center{
float:left;

}
#right{
float:right;
}
.inner{
	border-left: #7373F7 medium solid;
	border-right: #7373F7 medium solid;

}



This works perfectly for the alignment, but opened up another issue. The left and right borders are short of reaching the top and bottom borders. It can be forced to reach the bottom one by setting the height of the border tag, not a big deal. I can't seem to reach the top no matter what though. If I add the "inner" class before the div tags, it hides the border.





Thanks for the help so far. I never would have thought to put the borders is in a separate div tag!!!
Reply With Quote
  #7 (permalink)  
Old 10-10-2009, 10:36 AM
Junior Babbler
 
Join Date: Oct 2009
Location: Iowa
Posts: 10
Rooster has no reputation at Website Babble yet.
Send a message via AIM to Rooster Send a message via Yahoo to Rooster Send a message via Skype™ to Rooster
Default

I thought this might help. It's the style sheet in its entirety.


Code:
@charset "utf-8";
body {
	background-image: url(images/bckgrnd.png);
	background-repeat: no-repeat;
	margin: 0;
	padding: 0;
	text-align: center;
}

.container {
	background-color: #000;
	width: 80%;
	margin: 0 auto;
	padding: 0px;
	text-align: left;
}
#header {
	vertical-align: top;
	width: 100%;
}
.container #header h1 {
	font-family: "Times New Roman", Times, serif;
	font-size: 14px;
	font-style: italic;
	color: #666;
	text-decoration: underline;
	position: absolute;
	text-align: right;
	top: 61px;
	right: 196px;
}
#tvh    {
	right: 136px;
	position: absolute;
	top: 158px;
}
.container #MainContent {
	background-image: url(images/headerbck.png);
	background-repeat: repeat-x;
	height: 150px;
	width: 100%;
	float: left;
	border-top-width: medium;
	border-top-style: solid;
	border-top-color: #7373F7;
}
#left,#right{
width:15%;
background-color:#CC3300;
border-top: #7373F7 medium solid;
border-bottom: #7373F7 medium solid;

}
#center{
width:70%;
background-color:#333300;
border-top: #7373F7 medium solid;
border-bottom: #7373F7 medium solid;
}
#left,#center{
float:left;

}
#right{
float:right;
}
.inner{
	border-left: #7373F7 medium solid;
	border-right: #7373F7 medium solid;

}


It's probably totally screwed up LOL. I'm new to this whole style sheet thing.
Reply With Quote
  #8 (permalink)  
Old 10-10-2009, 01:08 PM
James's Avatar
Super Moderator
 
Join Date: Dec 2007
Posts: 2,750
James is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation barsJames is an elite member of WB with the maximum amount of reputation bars
Default Here you go...

Here is what I did and recommend. Instead of trying to go with the "inner" div's I went back to a more traditional approach. I also removed the float left from the center div because you want it to stay centered.

Next, I removed the 70% width from the center div. You will probably have problems later if you do not. When you float the sides or anything else like an image it floats inside the container it is in. So really the center div can be seen as wide as the whole, or you can use the container div for this. I am thinking you have more html just as you had more css. Anyway what you want to do is to have a margin on the right and left of the container or center div, whatever the containing tag is so that material in the center does not extend into the div's and the right/left and those can float up beside.

Also, you have to put the containing one below the floated tags or they won't locate right. To see this in action, move the center div up between the two side div's and the right one will drop down below the center.

I did not do it here but you need to remove the "center" text align (text-align: center from your body css. Otherwise every line of text will be centered through your page. It is better to center those fewer things you want centered.

[EDIT NOTE: I forgot to add back in the right and left borders but I tried and they work OK. Just add them to the left right and center div's.]

Here is the changed code:

<!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=iso-8859-1" />
<meta name="generator" content="NoteTab Pro" />
<title>*** Your Title Here ***</title>

<style type="text/css">
<!--
body {
background-image: url(images/bckgrnd.png);
background-repeat: no-repeat;
margin: 0;
padding: 0;
text-align: center;
}

.container {
background-color: #000;
width: 80%;
margin: 0 auto;
padding: 0px;
text-align: left;
}
#header {
vertical-align: top;
width: 100%;
}
.container #header h1 {
font-family: "Times New Roman", Times, serif;
font-size: 14px;
font-style: italic;
color: #666;
text-decoration: underline;
position: absolute;
text-align: right;
top: 61px;
right: 196px;
}
#tvh {
right: 136px;
position: absolute;
top: 158px;
}
.container #MainContent {
background-image: url(images/headerbck.png);
background-repeat: repeat-x;
height: 150px;
width: 100%;
float: left;
border-top-width: medium;
border-top-style: solid;
border-top-color: #7373F7;
}

#left, #right{
width:15%;
background-color:#CC3300;
border-top: #7373F7 medium solid;
border-bottom: #7373F7 medium solid;
}

#center{
margin-left: 15%;
margin-right: 15%;
background-color:#333300;
border-top: #7373F7 medium solid;
border-bottom: #7373F7 medium solid;

}

#left{
float:left;

}
#right{
float:right;
}

-->
</style>
</head>
<body>

<div id="left">
<p>Left Column</p>
</div>

<div id="right">
<p>Right Column</p>
</div>

<div id="center">
<p>Center Area</p>
</div>

</body>
</html>
__________________
Good Success!

Douglas County Master Gardeners
"We don't always get what we want, but we always get what we expect."

Last edited by James; 10-10-2009 at 01:28 PM.
Reply With Quote
  #9 (permalink)  
Old 10-11-2009, 08:24 PM
Junior Babbler
 
Join Date: Oct 2009
Location: Iowa
Posts: 10
Rooster has no reputation at Website Babble yet.
Send a message via AIM to Rooster Send a message via Yahoo to Rooster Send a message via Skype™ to Rooster
Default

I wanted to stop by and say thank you for all your help. At about 3:00am CST I got it fixed. The issue was with the main content area of the body. Along with the navbar was causing an issue. Somehow I fixed these issues using a combination of what you all were telling me and just trial and error. I changed a lot of the coding around to accommodate different browsers and users. Any way,

THANK YOU
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -6. The time now is 12:34 PM.


 Subscribe to RSS

WB Sponsors

flash chat

Home Jobs Online

Search Engine Marketing

Paid Surveys

Web Design Newcastle



 Subscribe to the Website Babble Feeds

2 Create a Website Homepage | 2 Create a Website Blog


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0