I have nothing on the page except two section elements. Both the sections take up 1280px of width and 800px of height. When I shrink the browser window width down to 1281px (using Chrome's Dev tool to see the window's width), a horizontal scroll bar appears as if I had shrank the windows width below 1280px. When I inspect the body element it shows me that it is 1264px in width. On the other hand, Dev Tool shows me that the window width is 1281px.
When I decrease the height of both the section elements to a value lower than the window's current height, for example 300px, the horizontal scroll bar disappears and the body width is shown to be 1281px.
I have also applied css reset on the page as well.
what is causing this and how to prevent this?
section#sec1{
background: orange;
}
section#sec2{
background: pink;
}
section{
display: block;
margin:0px auto;
width:1280px;
height:800px;
}
<section id="sec1">Some content</section>
<section id="sec2">Other content</section>
If you want jsfiddle: https://jsfiddle.net/L991shcp/
and the reset:
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}