Div width: 100% will exceed the border of the browser window
here is my code:
<body style="width:100%; height:100%; margin:0px">
<div id="horizontal-bar" style="width:100%; height:34px; border: 10px solid;"></div>
# the horizontal frame on the right is not displayed, how to do # the horizontal panel is completely displayed in the browser window if css cannot do this? can i do this in js?
+4
2 answers
Here you need to use box-sizing: border-box, because it is borderalso part of the block model:

(source: codemancers.com )
Excerpt
body {
width: 100%;
height: 100%;
margin: 0px;
}
#horizontal-bar {
width: 100%;
height: 34px;
border: 10px solid;
/* Add This */
box-sizing: border-box;
}<div id="horizontal-bar"></div>Your old broken code for comparison:
body {
width: 100%;
height: 100%;
margin: 0px;
}
#horizontal-bar {
width: 100%;
height: 34px;
border: 10px solid;
}<div id="horizontal-bar"></div>+8
