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
Aquib Javed
8,289 PointsHelp with CSS/Bootstrap in creating a sidebar that is responsive.
I'm trying to make a page with several panels using Bootstrap. The problem I'm facing, as shown in the pictures below, is that whenever I'm creating a sidebar with 3-column length, it's automatically pushing the row beneath it a little further down. Please refer to the pictures below:
I want the gap between two panels like this picture
I can get the above spacing if I manually set a height for the sidebar(any height, tried with 20px/50px/2px), but it causes a collapse of the sidebars if I then lower the size of my browser for a mobile view (i.e responsive).
If I don't however, set some height for the sidebars manually, it then creates a problem like this
So basically, I can get the expected spacing between the panels after setting up the sidebars, only if I manually set a height (any pixels of height, which is mainly confusing me), but which collapses if I go to the mobile view. But if I don't set the height, then it automatically pushes the panels beneath it. Can someone tell me how can I fix this issue And make sure that the sidebar doesn't collapse in a different viewport size?
Thanks!
2 Answers
Robert Manolis
Treehouse Guest TeacherIf I could see y the code I might be able to figure out what is happening
Robert Manolis
Treehouse Guest Teacherdid you try floating .col-lg-3 to the right to remove it from the DOM flow?
Also, what I find can really help with styling and spacing issues, is to open up the developer tools for your browser, the one that let's you see the markup and the box model, then you can literally see how much space is being applied where, and what might be getting your way.
I'm not really familiar with bootstrap yet, so I'm not sure what knew rules apply. Is it typical to add a lot of long class attributes in bootstrap? Are some of them for functionality or are they all just for refrencing?
Aquib Javed
8,289 PointsMost of these classes, as per my knowledge are applied for using Bootstrap's own generated css, so you don't really need to add much styling to your webpage, bootstrap does that for you. Will admit though, for a beginner like me, this long list of classes sometimes get a little too difficult, thanks for your help anyways!
Aquib Javed
8,289 PointsAquib Javed
8,289 Pointsokay here's the code:
and here's the CSS: