Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fill the entire width (React.js)?

Tags:

width

reactjs

i'm new to React.js and the first thing i noted is that the entire width of the page is not filled. This is my JS code:

var Navbar = React.createClass({
    render: function(){
        return(
            <div className="navbar"> </div>
        );
    }
});

ReactDOM.render( <Navbar/>,document.getElementById('test') );

And CSS:

.navbar{
    background-color: green;
    width: 100%;
    height: 3em;
}

There is a 3px top, left, right unexpected margin.

like image 249
Devcost Avatar asked Feb 25 '26 05:02

Devcost


1 Answers

Your body either has a margin or padding. You could remove but then it gets messy with other areas of the page you want to have even padding. Another option is you could make the navbar position fixed. which will ignore padding/margin.

.navbar{
  position: fixed;
  top: 0;
  left: 0;
  background-color: green;
  width: 100%;
  height: 3em;
}

http://codepen.io/finalfreq/pen/VKPXoN

like image 180
finalfreq Avatar answered Feb 26 '26 23:02

finalfreq



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!