Jump to content

Three Vertical divs, always same height?


Jessica

Recommended Posts

It helps if I follow my own advice sometimes ;)

 

Here's the CSS:

.introBar{
width: 240px;
padding: 5px;
float: left;
min-height: 400px;
height: auto !important;
height: 400px;
font-size: 1em;
color: #FFFFFF;
}

#about{
background-color: #353535;
text-align: justify;
}
#browse{
background-color: #404040;
}
#join{
background-color: #474747;
}

 

The HTML:

<div id="about" class="introBar">
<h1>About</h1>
<p>Blah!</p>
</div>

<div id="browse" class="introBar">
<h1>Browse</h1>
<p>blah blah</p>
</div>

<div id="join" class="introBar">
<h1>Join</h1>
<p>Blah</p>
</div>

Link to comment
Share on other sites

Hi Jesi

 

this might be a silly idea and may not even work but I think its worth saying and being laughed at...

 

could you not have one big div, with the 3 smaller vertical divs inside it set to 100% so all three would be same size as the outer div and that could be autoheight to the size of the three inner divs...make sense??????

Link to comment
Share on other sites

That still didn't work.

Here's the page, changed:

http://grady.us/scrapbook/

<div id="introBar">
<div id="about">
	<h1>About</h1>
	<p>blah blah</p>
</div>

<div id="browse">
	<h1>Browse</h1>
	<p>blah blah</p>
</div>

<div id="join">
	<h1>Join</h1>
	<p><?=SITE_NAME?> is free and it only takes a moment to join, so register now!</p>
</div>
</div>

 

#introBar{
height: auto;
}

#introBar div{
width: 240px;
padding: 5px;
float: left;
font-size: 1em;
color: #FFFFFF;
height: 100%;
}

#introBar div h1{
height: 55px;
overflow: hidden;
line-height: 100;
font-size: 0;
}

 

I also tried

#introBar{

min-height: 400px;

height: auto !important;

height: 400px;

}

Link to comment
Share on other sites

wildteen: It worked in 6, then I changed some stuff that broke in Fx, so it probably broke again by the time you saw it :)

 

If you find that tutorial, I'd really love to see it. Thanks :) I'm off to scour Google.

 

Edit: The method I normally use is to make a background image and tile that along the container div - I'd like to try to avoid that this time and see if I can actually get the divs to work right.

 

Edit2: Here's an interesting JS approach:

http://tylerkaraszewski.com/experiments/equalheightdivs/equalheightdivs.html

 

Not going to use it, but maybe someone else will.

Link to comment
Share on other sites

A real easy fix is just use a background image for introBar...just take a screenshot of your columns, select a 1px height for the whole way accross and set that as your background image. this way all of your columns will look equal.

 

I hope that made sense :)

Link to comment
Share on other sites

I read that one, and it looks way more complicated than the image method. I'll stick with faux columns for now I guess.

 

I like comment #9 there.

 

"Opening a keylock with a paperclips is an ingenious and spectacular magician’s act. But would you seriously buy such a lock?

 

Using negative margins is an unintended use of the standard. Boxes don’t have negative margins. How a browser handles them is not a bug but an implementation choice (a respectable one being to simply ignore out of range values).

 

A standard defines what can be done, but also what should not be done (even if it can be done). This is where many css techniques abuse the standard.

 

I think this is a real issue. As a newbie, I buy solutions such as this one, thinking that I am investing in a solid foundation. Then I try to add a menu or an image or even a simple italic, and have no clue why things suddenly mess up. As it dawns to me that I am really investing in implementation exploits, I am ready to throw away this whole css mess altogether. Now that would be an unintended consequence?

 

My apologies if this sounds as a harsh critique on this work. It is a superb solution to a real problem. Only it requires a magician to make it work in daily life."

Link to comment
Share on other sites

To be honest I tried to implement the technique over the weekend and ran into IE6 issues with the negative margins... but I thought I would at least introduce the solution as it might help someone else.

 

No kidding. IE6 is a pain when it comes to depending on negative margins. jesi, I agree with the consensus that, as of now at least, faux columns are the way to go. However, I would encourage simply applying a content wrapper around your three columns and using the CSS only clearfix for IE6.

 

I implemented it in my sandbox here for anyone that's interested in seeing the method I regularly use. Yes, it's still using faux columns, but the markup stays quite clean with this CSS fix.

 

Hope it helps someone... once you have the entire method down, it only took about 20 minutes to set the whole thing up.

Link to comment
Share on other sites

Since I already had the CSS from the last time, it just took me the few seconds to recolor the image :)

 

Good call. I figure after some of the other time comments made in other recent threads that 20 minutes from start to finish, including image creation, hand coding all styles and posting the site was not too bad. ;)

 

Definitely better to modify one that's already there, though.

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.