...

View Full Version : Background color in div column - stretch 100% vertical?



pilsnermonkey
01-19-2013, 10:46 PM
I have a 3 column liquid layout. All columns are liquid: .sidebar1 (left is blue color background - no images) .content (middle is white background - no problems) and .sidebar2 (right is blue background color). 20% - 60% -20%. They live within .container which sets full page view at 90% with max-width: 1260px and min-width: 780px.

I'm struggling with an issue that seems common but I have not found a solution that works yet. The center column (.content) varies in length on a number of pages based on how much info and text the page contains. Some are long and scroll.

The content in sidebar1 div column and sidebar2 div column is generally not as long as the .content column. The result is a short blue colored column on the left and a short blue colored column on the right.

I would like those two blue columns to stretch to the bottom of the page on all pages regardless of the amount of text & stuff in the .content div, hopefully using only the background color property instead of an image. (I think the flexible nature of the 2 sidebars would make an image background too complicated and possibly inconsistent across browsers and screen resolutions.)

Initially, I messed and messed with 4 main divs plus a footer div. No luck no matter what tweak I applied. After searching a lot, it looks as though I need to place the 2 .sidebar columns within a container so I've created .sidebar1container and .sidebar2container and wrapped those around .sidebar1 and .sidebar 2..

Am I on the right track? Is anyone familiar with this issue and have a potential solution?



Original HTML
HTML
<div class="container">
<div class="sidebar1">
<div class="content">
<div class="sidebar2">

Original CSS
.container {
width: 90%;
max-width: 1260px;
min-width: 780px;
}

.sidebar1 {
float: left;
width: 20%;
background-color: #93A5C4;
padding-bottom: 10px;
color: #FFF;

}

.sidebar2 {
float: left;
width: 20%;
background-color: #93A5C4;
padding: 1px 0;

}

.content {
padding: 10px 0;
width: 60%;
float: left;
}

NEW HTML direction
<div class="container">
<div class="sidebar1container"
<div class="sidebar1"></div>
</div>
<div class="content"></div>
<div class="sidebar2container">
<div class="sidebar2"></div>
</div>

NEW CSS direction
.container {
width: 90%;
max-width: 1260px;
min-width: 780px;
}

.sidebar1container {
????
}

.sidebar1 {
float: left;
width: 20%;
background-color: #93A5C4;
padding-bottom: 10px;
color: #FFF;

}

.sidebar2container {
???
}

.sidebar2 {
float: left;
width: 20%;
background-color: #93A5C4;
padding: 1px 0;

}

.content {
padding: 10px 0;
width: 60%;
float: left;
}


Thanks for looking.

Excavator
01-20-2013, 01:33 AM
Hello pilsnermonkey,
I'm not sure the point of nesting your sidebars in sidebar containers. I think one of the indicators of divitis (http://www.apaddedcell.com/div-itis) is when you can't come up with any styling for an element. -

.sidebar1container { ????
}.sidebar2container { ???
}

Normally the solution to your problem would be faux columns. Google that for a ton of examples. Since your layout is in %'s, faux columns may not work so well.
Have a look a this jQuery solution - http://nopeople.com/CSS%20tips/jQuery_equal_columns/index.html

pilsnermonkey
01-20-2013, 05:01 AM
Perfect. That is beautiful. Works perfectly. Thank you so so much! Really appreciate the help Excavator. Helpful Member +++

pilsnermonkey
01-20-2013, 07:19 PM
Just one afterthought. If you happen to know of the top of your head: prior to introducing that HTML5 bit, my page was an XHTML doctype. I changed that to HTML doctype prior to adding the <aside> tags. Is that a necessity or would the HTML 5 bits work in an XHTML doctype environment?

Also, are the <aside> tags in any way dependent on the <section> tag or should they be happy all on their own?

Excavator
01-20-2013, 10:07 PM
Just one afterthought. If you happen to know of the top of your head: prior to introducing that HTML5 bit, my page was an XHTML doctype. I changed that to HTML doctype prior to adding the <aside> tags. Is that a necessity or would the HTML 5 bits work in an XHTML doctype environment?

There are plenty of new elements that depend on the HTML5 DocType Declaration and won't be recognized by an XHTML DocType.




Also, are the <aside> tags in any way dependent on the <section> tag or should they be happy all on their own?
You can find hours of reading on the new HTML5 elements and the correct way to use them. Here's a start - http://html5doctor.com/element-index/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum