0

First off, my FE skills are pretty basic so sorry upfront if this a silly question...

I'm trying to create a basic blog page and I'm having trouble with the layout of the content div and the post links div. I want them to be kinda float side by side so that they have a margin from each other, the sides and the header/footer.

I'm using react-bootstrap for that and it sort of works but what I can't figure out why the content div has no margin from the top and the sidebar div does..

here is my site: https://tal-joffe.github.io/blog (ignore the ugly colors and fonts I just started :) )

this is the component that contains both divs:

const PostsTab = () => (
    <div className="post-tab">
        <Grid>
            <Row>
                <Col md={8}>
                    <ContentContainer/>
                </Col>
                <Col md={4}>
                    <VisiblePostsList/>
                </Col>
            </Row>
        </Grid>
    </div>
)

And this is the css I have for the inner components on the containers and the body:

.side-bar {
  background-color: gray;
  min-height: 800px;
}
.post-content{
  background-color: #efefef;
  min-height: 800px;
}

body {
  font-family: sans-serif;
  background-color: aquamarine;
  overflow: auto;
}

There is no other global css code and I don't use any inline styles in the javascript code.

What am I missing?

2
  • Why should they have a "margin-top"? Commented Jul 16, 2017 at 15:46
  • @Andrew I just think it looks better. regardless I'm trying to improve my frontend capabilities and wanted to understand why would the 2 divs act differently Commented Jul 17, 2017 at 10:36

1 Answer 1

2

There's no margin on either column. Browsers give HTML heading tags margins. In your case, the sidebar's h2 tag is the reason the sidebar looks like it has a margin on the top. Try styling the h2 with margin-top: 0;

You should add a margin-top style to .row or .container. Hope this helps!

Sign up to request clarification or add additional context in comments.

1 Comment

thanks that was exactly the issue. I didn't know tags inside the div could have an impact...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.