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

Creating a sidebar(?) with it's own flow?

Hello! I am struggling on creating a sidebar with it's own flow. I am using Bootstrap 3.

So I want to use approximately 70-80% of the page for the main content. But I also want a sidebar to the right with it's own flow. I am trying to find something about it on the web but I can't find something specific.

The thing I have been trying out so far is giving my left columns a class of "col-md-8" and the right ones "col-md-4". But when I create more of them they operate in the same flow which is something I don't want. Best Regards.

3 Answers

Hi Sebastian,

I am not 100% sure what you mean by 'flow' in this question.

However, you could try something like this. For the CSS of the 'sidebar' try:

.yoursidebar {
    position: fixed;
    width: 20%;
    overflow-y: scroll;
    top: 0;
    bottom: 0;
}

Obviously you want to replace '.yoursidebar' with the class for the sidebar.

Hope something like this helps

What I meant by "flow" is that I want to be able to create as many columns as possible to the sidebar, and that shouldn't effect what is in the main container. Kind of like a separate container, as if you would browse a totally different site.

This is what happens when I insert your code to the sidebar: https://gyazo.com/3ba31c1fc1e7d4ad4b2462b63070f148

This is my HTML:

<div class="wrapper">

    <div class="container main-contain">
        <div class="row">
            <div class="col-lg-8">
                <h2>Dolphins</h2>
                    <div class="small">Created: <a href="#">17:34 27/08-15</a></div>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat.</p>  
            </div>  
            <div class="col-lg-4 sidebar">
                <h3>Lions</h3><div class="small">Created: <a href="#">17:34 27/08-15</a></div>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
                cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
                proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
            </div>
        </div>
    </div>

Ah okay. I think I mis-understood your meaning of 'flow'

My code is to create a sidebar that scrolls separately to the normal webpage. I thought this is what you meant by it's own 'flow'

I was not specific enough. I made a picture that illustrates it pretty clear I believe.

https://gyazo.com/217828b3a0e741488592dc42cb2f505a