Forum Moderators: not2easy

Message Too Old, No Replies

how to prevent overlapping

         

ady123

6:47 am on May 30, 2008 (gmt 0)

10+ Year Member



hi,
i'm a newbie.. i have problem with the css.. the web page is in 3 column structure. center having the main content. problem is content in the center is overlapping the content in the right column. is there any method to avoid that, so that size of the center part can expand and shrink according to the content. pls help me...

vincevincevince

7:00 am on May 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I suggest that you set a width: on the middle column, but not a height.

ady123

7:17 am on May 30, 2008 (gmt 0)

10+ Year Member



ya, but in some pages contents are short, but some contains big pictures which overlap to right column. so if i set a width then al pages hav to be huge na?

vincevincevince

7:32 am on May 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



then, you use float:left on each column, then the right column will always move out around the middle one

ady123

8:03 am on May 30, 2008 (gmt 0)

10+ Year Member



float: left is not helping. right column goes down(only tat column dere)

vincevincevince

11:58 am on May 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<div style="float:left;width:100px">LEFT</div>
<div style="float:left;">MIDDLE</div>
<div style="float:left;width:100px">RIGHT</div>

genevevex

12:36 pm on May 30, 2008 (gmt 0)

10+ Year Member



I have a website of similar design that I work on. I really had to do some tweaking to get that layout to work.

#container {
position: relative;
display: block;
background: #FFFFFF; /* background color of the middle */
border-left: 200px solid #55834D; /* background of left */
border-right: 200px solid #BBCDB8; /* background of right */
overflow: visible;
padding: 0px;
margin: 0px;
}

#left {
float: left;
position: relative;
width: 200px;
margin-left: -200px;
display: inline;
}

#right {
float: right;
position: relative;
width: 198px;
margin-right: -197px;
display: inline;
}

.textpad {
padding: 5px;
margin: 0px;
}

#contents {
padding: 0px;
margin: 0px;
}

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<head>
<!-- *******For internet explorer to see properly******* -->
<!--[if IE]>
<style type="text/css">
#container {display:inline-block;}
#left {width:197px;}
</style>
<![endif]-->
</head>

<body>
<div id="container">
<div id="left">
Left side contents here
</div>

<div id="right">
Right side contents here
</div>

<div id="contents">
<div class="textpad"> <!-- gives content some spacing so it isn't jammed up against the sides -->
Middle contents here
</div>
</div>

</div>
</body>

You can modify the sizing of the left and right sides to fit your needs. Also, I used the textpad in both the right and left sides as well as the middle area, so that my content of those areas wasn't jammed up against the other areas. I only showed it in the middle section in the example, though. You can use it to suite your needs, or just leave it out.

I hope this was helpful.

ady123

4:08 pm on May 30, 2008 (gmt 0)

10+ Year Member



thnks..ill try this and see if it helps:-)

londrum

4:17 pm on May 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



another way of doing it is to give all three columns 100% width, and then apply some padding to them.
you'll have to position them absolutely though, rather than relatively.

#column1, #column2, #column3 {
position: absolute; top: 0; left: 0; width: 100%;
}

then give the first column 66% of right-padding,
give the second column 33% padding each side,
and give the third column 66% of left-padding.