Solved

CSS column trouble

Posted on 2014-01-31
7
277 Views
Last Modified: 2014-01-31
Good morning. I am having trouble with CSS columns. On this page:

http://test2.ebwebwork.com/pages/The-Book.cfm

You can see that the white, left column and the orange, right column are of different lengths. What can I do to make them the same length .... to both line up at the bottom of the container, even if one column has a lot more content than the other?

Thank you for your help. Here is the CSS / HTML:

.grid{
max-width:1020px;
margin:auto auto;
padding:0;
background-color:#fff;
}

.col_4	{
padding:1%;
margin-top:0;
margin-right:2%;
margin-bottom:0;
margin-left:0;
width:30%;
float:left;
}

.col_8	{
padding:1%;
margin-top:0;
margin-left:2%;
margin-right:0;
margin-bottom:0;
width:66%;
float:left;
}

.col_12	{
padding:0;
margin:0;
clear:both;
background-color:#292929;
}

Open in new window


<div class="col_8" style="background-color:#fff;">


<h1>The Book</h1>
<p>Left content here.</p> 

</div>



<div class="col_4" style="background-color:#f39c22;">

<p>Right column content here.</p> 

</div>

Open in new window

0
Comment
Question by:Eric Bourland
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 33

Expert Comment

by:Big Monty
ID: 39824317
try adding a min-height: 109px; to both columns and see if that resolves the issue
0
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39824341
If the content is going to be static, the best thing is to give the 2 divs the same class to make them the same height.


.col{height:300px;}

Open in new window

or even better
@media (min-width: 768px){
.col {height:300px;)
}

Open in new window

<div class="col_8 col" style="background-color:#fff;">


<h1>The Book</h1>
<p>Left content here.</p> 

</div>



<div class="col_4 col" style="background-color:#f39c22;">

<p>Right column content here.</p> 

</div>

Open in new window


fyi at line 119 to 123 you have and extra closing li tag that needs to be removed.
</li>


</li>
</ul> 

Open in new window

0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39824385
If no static height for the columns then pop this in before you closing body tag.

<script>
$(function() {
	getmaxheight = Math.max($('.col_12.column > .col_8.column').height(),$('.col_12.column > .col_4.column').height());
	$('.col_12.column > .col_8.column').height(getmaxheight);
	$('.col_12.column > .col_4.column').height(getmaxheight);
})
</script>

Open in new window

Though it would be better to give your sidebar and content div a unique class to target rather than using bootstraps classes.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:Eric Bourland
ID: 39824402
Friends,

Thanks for these ideas.

>>>fyi at line 119 to 123 you have and extra closing li tag that needs to be removed.

Fixed. Good catch, Scott. Thank you.

>>>min-height: 109px

Tried that ... fraid that did not do the trick.

Cathal I am trying your idea now. BRB.

Eric
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 39824411
Cathal, your solution worked quite well.

Question:

>>>Though it would be better to give your sidebar and content div a unique class to target rather than using bootstraps classes.

Can you give me an example? I would like to do this right. =)

Thank you. =)

Eric
0
 
LVL 58

Assisted Solution

by:Gary
Gary earned 500 total points
ID: 39824425
You have these two divs - one is the main content and one is the sidebar
<div class="col_8 column">
...
</div>
<div class="col_4 column">
...
</div>

Open in new window

Just add another class e.g.
<div class="col_8 column main-content">
...
</div>
<div class="col_4 column sidebar">
...
</div>

Open in new window

Then we can tidy up the javascript and do better targeting.
<script>
$(function() {
	getmaxheight = Math.max($('.main-content').height(),$('.sidebar').height());
	$('.main-content').height(getmaxheight);
	$('.sidebar').height(getmaxheight);
})
</script> 

Open in new window

0
 
LVL 3

Author Closing Comment

by:Eric Bourland
ID: 39824439
Makes sense and works like a charm. Thank you Cathal. Thank you also Scott and Monty.

Hope you all have a really good day.

Eric
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question