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

HTML

eslam said
PLUS
eslam said
Courses Plus Student 6,734 Points

Layout

What if i want to put a div exactly in the middle and a sidebar to the left? should i use 2 columns and make the div start at the start of the second columns ? here is an image https://prnt.sc/jnnwuh

4 Answers

Ray Karyshyn
Ray Karyshyn
13,443 Points

Here is a quick CodePen I whipped up -> https://codepen.io/raykaryshyn/full/jKNQGO/

I would overlay another flex grouping with two divs that have a width of 50%.

Ray Karyshyn
Ray Karyshyn
13,443 Points

Hi Eslam,

I would personally use CSS Flexbox (link to a guide by CSS-Tricks) and make 3 columns of equal width. Then, I would only put content in the first two columns.

Let me know if you need any help coding it up.

eslam said
eslam said
Courses Plus Student 6,734 Points

Hello Ray thank you so much for your answer, so is it okay to leave an empty div for the last column ?

Ray Karyshyn
Ray Karyshyn
13,443 Points

Yes, that is totally okay! In fact many pure CSS drawings use empty divs.

eslam said
PLUS
eslam said
Courses Plus Student 6,734 Points

Sorry Ryan i forgot to mention something what if i will put a text over the middle div like that ? http://prntscr.com/jnstjp

i am sorry for so many question