Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Getting the box go all the way down

How can this box go all the time down to the footer? or at least go as down as it need to ?

http://scr.hu/2icp/oz64z

8 Answers

Wayne Priestley
Wayne Priestley
19,579 Points

Hi Aurelian,

the only way i could get the effect you want without any content in the box was to use bottom padding and a negative bottom margin. But thats only going to work if your website stays the same. when you add content on the right you would have to adjust these settings every time. Not good. I think java script would work by i couldn't help you much in that area.

I will post the code i used so you can see my result, but it would be a pain to do it this way if your going to be adding content on the right or in the grey box as you would have to keep changing this code.

#leftBar{
    background: grey;
  width: 350px;
    float:left;
  padding-bottom: 1569px;
  margin-bottom: -1569px;
}

lal :D it worked ! I never say this thing working like that . Well for now as for one page , i just need it so it goes all the time down but when i go on JS or PHP , i hope i can learn about it more. Well for the moment i want to do a search thingy like forms in treehouse , options etc... so see how it gonna go and well i hope to learn things i need in 3 motnhs so i can do a website i want and post is and then upgrade skills . Thank you :) and thats a new way to do things . as doing that trick .

you know what? they should do english courses too , more people would come here : p

the only problem is that when i did it , and looked at footer , etc... it didnt look good

Wayne Priestley
Wayne Priestley
19,579 Points

Aurelian,

First, Your using a div with an id for your footer, you should change that for the specific footer tag.

You also have the same going on with the header, you should change that from a div with a id to the specific header tag.

Same with your navigation, change the div with the id of navbar to the specific nav tag.

You have used id in a few places when class would be more appropriate, it has a higher specificity.

Your footer has a margin on the left, the reason for that is that you have stated a margin for your outer div and your div with the footer id is within that div.

In your left bar id you have a padding property but no value entered, I have noticed that in a few other places too.

One final thought for now, your using a lot of different positioning values throughout your css, this will complicate things a lot for someone just beginning, I would suggest removing them, getting your content in place then working on the positioning, I'll be here to help you out.

For now, you should look at what I have mentioned and work on that, the more we can simplify things and get the semantics correct the easier it will be to get what look you want.

:)

Im not sure what you mean by that " Your footer has a margin on the left, the reason for that is that you have stated a margin for your outer div and your div with the footer id is within that div. "

Im not sure what you mean by that too but im guessing and if im right , im not sure how to fix it .

" In your left bar id you have a padding property but no value entered, I have noticed that in a few other places too."

The thing is that id like to make it go fluid , but im not completely 100% sure how to do it . Like if you look on my leftBar , make a margin inside and the content on the right will move down.

New changes http://codepen.io/anon/pen/xinKf

Wayne Priestley
Wayne Priestley
19,579 Points

You have a outerdiv in your css, one of the values you have is margin 0 auto. That margin is going to be applied to everything within that outerdiv until you close the outerdiv. Your outerdiv does not close until the very end of your html. the div you have with the id of footer is therefor within that outerdiv opening and closing so it has the margin of 0 auto applied to it.

There are a few places that look like this:

#leftBar{
    background: white;
    height: 1200px;
    width:348px;
    float:left;
    position:relative;
    border-right: 1px solid grey;
    padding
}

You notice the padding has nothing added as a value, e.g. 10px there are a few other instances of that too.

I understand your eager to get things done, but the better you write your html and css the easier it will be to get the layout you want.

Well, i try to make it clear , and i think i did the user feed quite clear but other stuff, is a bit messed up that i though it will work out fine . Like you see here on left bar , i have width od 348px , but it should be 350px and when i wanted to put a margin or border , i had to move it out to 348px from 350px because i applied border-right 1px soid grey , but it shoudnt move all the thing . Whateer i do , it get a bit messed up now ;/

Wayne Priestley
Wayne Priestley
19,579 Points

When you add a border your adding the px to the outside, there are things you do in your css (box-sizing) to make sure the border is added on the inside.

When you added the border it changes the overall width of your content and things will be moved to accommodate that. I really can't stress enough how much easier things are if you first get all the basics right, then as you change things one at a time you can see straight away if something causes a change you didn't expect, and that way you know exactly what works or not.

What would you recomend me to do with that box layout with two collumns or more ? i mean like if i add border it wont move apart int he box or something ?

Wayne Priestley
Wayne Priestley
19,579 Points

My honest recommendation Aurelian would be to work on the html first and get things fixed in there first, then slowly rework the css so your seeing exactly what each change does one step at a time.

Its really hard I know, when i started I wanted to go all out and do the css at the same time as the html so i could see things happening as i coded, the thing is its too easy to get lost in the code and end up trying to fix things instead if making things.

Learning is a slow and steady thing, once you get to a stage where you know more you can do a bit of html and css at the same time as you'll know what your doing.

Like I said its hard, there is a lot you can do to the html to improve things, I'm willing to help you out as much as you want me too, but i have to say its more fun coding that trying to fix one thing, then that breaks another, you end up taking the fun out of coding.

If there is no rush then thats my suggestion.

Hope it helps Aurelian.

What do you think if i make a plane on paint what i want to do and then i code it on HTML and then post it here and after that i add step by step css?

ah bdw , in Design Color i think , there was a paragraph mentioned to you :p but since the other guy had the MOD it confused me and i thought im writing with you

Wayne Priestley
Wayne Priestley
19,579 Points

I think thats an excellent idea Aurelian.

One thing I just noticed looking over your html again is that you have your css loaded then after that you have normalise loaded. Thats the wrong way round, thats probably caused a lot of the issues you've had.

Your new idea is an excellent way of doing things, and ill help you out as much as possible.

Wayne Priestley
Wayne Priestley
19,579 Points

What code are you using for the box at the moment Aurelian?

"""

leftBar{

background: grey;
height: 200px;
width:350px;
float:left;

}

""" if i delete height and put it on auto , it desapears . I tried to solve it in many ways before aswell and never found the answer . and oh my browser was on 75% zoom out and everything is too big when its on normal :(

Wayne Priestley
Wayne Priestley
19,579 Points

What about entering a height of 100%

What will the box be used for Aurelian?

A height of auto will need content in so it has something to adjust too.

height on 100% doesnt work , it has a width that is pushing to i think that would work . Well i have header on left bar and height on 100% , it doent work .

It sounds like you need to apply a similar practice as with the 'sticky footer'. http://ryanfait.com/html5-sticky-footer/

Or give it a positioning of 'fixed' and a bottom position (bottom:X;) of whatever you footer height is. if you footer is 20px tall then bottom: 20px; for example. let me know how those ideas work for you.

i dont quite understand it , not sure what you mean and not sure what is that website doing because i dont see html code

Wayne Priestley
Wayne Priestley
19,579 Points

It maybe a issue with other elements you have on the page if your using floats and relative positioning with some things and fixed or absolute with others, if you could post your html and css here, or code pen would be good so we can try different solutions.

heres the code http://codepen.io/anon/pen/pegvi

Yes everything is too big , too much effort to change it on 100% zoom as i have it on 75% :/ probabily my mum hanged the zoom :(

and i use normalize css but if i paste it here , it would load forever.

This is the classic 'equal-height columns' problem. In short, there is no way to easily achieve the effect you're looking for. If your left-hand column must be a different colour to white, then immediately you have a problem.

However, there are ways, and no-one can sum it up better than this post: http://css-tricks.com/fluid-width-equal-height-columns/

Wayne Priestley
Wayne Priestley
19,579 Points

If its messed up your footer you'll have to adjust the pixel sizes in the Padding and margin, but make sure you keep them the same number but remember the margin is a negative number.

Like I said this is far from the best option but it will work until you make changes.

well , it goes throw the footer covers all and the line , the border is messed up coz it goes all the way down. and it sort o wrong

Wayne Priestley
Wayne Priestley
19,579 Points

Do you want to post it to code pen again and post a link for me to take a look?

The thing i want is to make clear , to clear ti so it goes automaticly with the code . Its a one page divided but im not sure where to put clear .

http://codepen.io/anon/pen/DeHfq