Solved

CSS column trouble

Posted on 2014-01-31
7
275 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 52

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
Independent Software Vendors: 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

726 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