Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
2 Div tags always same hight
Old 12-09-2010, 12:13 PM 2 Div tags always same hight
Average Talker

Posts: 26
Name: Adam Kischinovsky
Trades: 0
Hi I'm tryng to make two boxes on my page always the same hight, no matter how much text is inside one of them.

So the boxes will always be the hight of the box with the most text.

you can see what I meen here:

http://wearecrunch.dk/test-globeaid/

I would wan't both boxes to be the hight of the one to the right with the most text.

this is my css:

#indexcontent{
background-color:#336699;
border-top:#2175a5 solid 10px;
padding:10px 10px 10px 10px;
display:inline;
position:relative;
width:421px;
float:left;
}

#indexblog {
background-color:#3333FF;
border-top:#2175a5 solid 10px;
padding:10px 10px 10px 10px;
position:relative;
width:421px;
float:left;
margin-left:100px;

I hope you can help, thank you.
Kischi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-09-2010, 12:32 PM Re: 2 Div tags always same hight
Skilled Talker

Posts: 59
Name: Lisa Forgan
Location: Colorado
Trades: 0
There are a couple ways around this. One method would be to have a div used as a column-container wrapper around the left and right columns. In your css, you can have a background image on this "column-container" that repeat-y. It won't make the left and right column be the same height but it will look like it.

Now the other method is to use javascript. It will make the left and right column equal. You will need to change the id's to match your the ones in your code:

var ddequalcolumns=new Object()
//Input IDs (id attr) of columns to equalize. Script will check if each corresponding column actually exists:
ddequalcolumns.columnswatch=["columnLeft", "columnRight", "mainBody"]

ddequalcolumns.setHeights=function(reset){
var tallest=0
var resetit=(typeof reset=="string")? true : false
for (var i=0; i<this.columnswatch.length; i++){
if (document.getElementById(this.columnswatch[i])!=null){
if (resetit)
document.getElementById(this.columnswatch[i]).style.height="auto"
if (document.getElementById(this.columnswatch[i]).offsetHeight>tallest)
tallest=document.getElementById(this.columnswatch[i]).offsetHeight
}
}
if (tallest>0){
for (var i=0; i<this.columnswatch.length; i++){
if (document.getElementById(this.columnswatch[i])!=null)
document.getElementById(this.columnswatch[i]).style.height=tallest+"px"
}
}
}

ddequalcolumns.resetHeights=function(){
this.setHeights("reset")
}

ddequalcolumns.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
}

ddequalcolumns.dotask(window, function(){ddequalcolumns.setHeights()}, "load")
ddequalcolumns.dotask(window, function(){if (typeof ddequalcolumns.timer!="undefined") clearTimeout(ddequalcolumns.timer); ddequalcolumns.timer=setTimeout("ddequalcolumns.re setHeights()", 200)}, "resize")
Puddlemut is offline
Reply With Quote
View Public Profile
 
Old 12-09-2010, 04:15 PM Re: 2 Div tags always same hight
Average Talker

Posts: 26
Name: Adam Kischinovsky
Trades: 0
Hi, thx for the answer.

But I'm not sure I understand, I will tru the first method with the column-container. because I don't really understand much of javascript.

So do you meen just put the 2 boxes inside a container and give the boxes the same color as the container or what?

I've tried it now, how I thought you said, is it correct:

http://wearecrunch.dk/test-globeaid/

this is my css code:

Code:
#indexcontent{
    background-color:#336699;
    border-top:#2175a5 solid 10px;
    padding:10px 10px 10px 10px;    
    display:inline;
    position:relative;
    width:421px;
    float:left;
}
    
#indexblog {
    background-color:#3333FF;
    border-top:#2175a5 solid 10px;
    padding:10px 10px 10px 10px;    
    position:relative;
    width:421px;
    float:left;
    margin-left:100px;
    /*display:inline;*/
}
    
#column-container {
    background-color:#333366;
    width:1000px;
    float:left;
    background-repeat:repeat-y;
    }
and this is my html

Code:
<div id="column-container">

 <div id="indexcontent">dwqdwqf<br>
 dnjkwlka<br>
 dsadsa<br>
 daDASDS<br>
 dsadsadas<br></div>
 <div id="indexblog">dsadfw<br>
 few<br>
 fe<br>

 </div>

</div>
Kischi is offline
Reply With Quote
View Public Profile
 
Old 12-09-2010, 09:28 PM Re: 2 Div tags always same hight
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
The easiest way to do this is with the faux columns method -- check our stickies or Google it.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 12-10-2010, 12:40 PM Re: 2 Div tags always same hight
Skilled Talker

Posts: 59
Name: Lisa Forgan
Location: Colorado
Trades: 0
[QUOTE=Kischi;1117157]Hi, thx for the answer.

But I'm not sure I understand, I will tru the first method with the column-container. because I don't really understand much of javascript.

So do you meen just put the 2 boxes inside a container and give the boxes the same color as the container or what?

I've tried it now, how I thought you said, is it correct:

http://wearecrunch.dk/test-globeaid/

this is my css code:

Code:
#indexcontent{
    background-color:#336699;
    border-top:#2175a5 solid 10px;
    padding:10px 10px 10px 10px;    
    display:inline;
    position:relative;
    width:421px;
    float:left;
}
    
#indexblog {
    background-color:#3333FF;
    border-top:#2175a5 solid 10px;
    padding:10px 10px 10px 10px;    
    position:relative;
    width:421px;
    float:left;
    margin-left:100px;
    /*display:inline;*/
}
    
#column-container {
    background-color:#333366;
    width:1000px;
    float:left;
    background-repeat:repeat-y;
    }
and this is my html

HTML Code:
<div id="column-container">

 <div id="indexcontent">dwqdwqf<br>
 dnjkwlka<br>
 dsadsa<br>
 daDASDS<br>
 dsadsadas<br></div>
 <div id="indexblog">dsadfw<br>
 few<br>
 fe<br>

 </div>

</div>

You are really close. Lets just tweak the css a little. Lets see if I can give a very quick explanation of what I've changed in the code below. First you'll create an image of the background you'll repeat (attached). This image will be the background of your column-container and it will repeat-y. I also put the clear/overflow because you have floating elements. For #indexblog and #indexcontent, I just removed the background color as you won't need it anymore.
Try it out and see what you get. Hope this helps


#column-container {
background: url (your image path goes here) 0 0 repeat-y;clear: both;
overflow: hidden;
width:982px;
}

#indexblog {
border-top:#2175a5 solid 10px;
padding:10px 10px 10px 10px;
position:relative;
width:421px;
float:left;
margin-left:100px;
}

#indexcontent{
border-top:#2175a5 solid 10px;
padding:10px 10px 10px 10px;
display:inline;
position:relative;
width:421px;
float:left;
}
Attached Images
File Type: gif bkgd.gif (1.1 KB, 0 views)

Last edited by chrishirst; 12-10-2010 at 04:41 PM..
Puddlemut is offline
Reply With Quote
View Public Profile
 
Old 12-18-2010, 01:36 PM Re: 2 Div tags always same hight
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,376
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You will have to use javascript to adjust the heights, CSS can only push the parent container height

http://www.candsdesign.co.uk/article...eight-columns/
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-18-2010, 05:50 PM Re: 2 Div tags always same hight
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Or... you could use an easy jQuery plugin:
http://www.cssnewbie.com/equalheights-jquery-plugin/
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to 2 Div tags always same hight
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 4.28690 seconds with 13 queries