Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm learning how to make a simple template with CSS e HTML5 but i've got a problem: i want to make a container with sidebar and articles list but it dosen't work. See to believe: http://informaticalab.com/template.html

That black line, should be a simple border that contains both the elements. Thanks for help and sorry for bad english, Federico

share|improve this question
Can you either accept an answer or provide more direction on question? Thanks. – cgx May 3 at 19:00

migrated from webmasters.stackexchange.com Apr 28 at 15:02

1 Answer

up vote 0 down vote accepted

It looks like you have an extraneous </div>, which is one problem :) It's removed in the fiddle below.

If you're using floating elements, which you are, you will need to clear those floats in order for the container to 'stretch' to the bottom of the content.

An easy way to do that is create a new class called "clear" or something similar with the following:

.clear {
    clear:both;
}

However, the downside is that you're introducing a new dom element simply to modify the layout.

Another solution (courtesy of Quirksmode http://www.quirksmode.org/css/clearing.html) is to tell the containing element to deal with these floated elements:

#container {
    ....old code...
    overflow: auto;
    width: 100%;
}

This has a few quirks under certain circumstances, so it's up to you which you choose to use.

See the fiddle here: http://jsfiddle.net/callseng/kZB5j/

This uses the clear element method.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.