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 trialeslam said
Courses Plus Student 6,734 PointsLayout
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
13,443 PointsHere 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
13,443 PointsHi 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
Courses Plus Student 6,734 PointsHello Ray thank you so much for your answer, so is it okay to leave an empty div for the last column ?
Ray Karyshyn
13,443 PointsYes, that is totally okay! In fact many pure CSS drawings use empty divs.
eslam said
Courses Plus Student 6,734 PointsSorry 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
eslam said
Courses Plus Student 6,734 PointsThank you so much