This is what I want
If browser is bigger than 900px I want the boxes to be 700px.
Once the browser width is smaller than 900px I want the boxes to be 600px.
@media screen and (min-width : 750px) and (max-width : 900px) {
.multiSelect .checkboxLayer {
width: 600px;
}
}
@media screen and (min-width: 900px) {
.multiSelect .checkboxLayer {
width: 700px;
}
}
My question is, how come the browser width splits around 932px and not 900px?
What units are these if not pixels?
I just tried to measure the browser width with photoshop and it splits at 975 px exactly.
So CSS says 900 px, Chrome says 932 px and photoshop says 975 px
This is really confusing?!?!
2
Answers
Scroll bar width is 17px on most browsers, and does not contribute to the screen width. Try using Firefox’s responsive design mode, in the dev tools.
The short answer:
You have not reset the
box-sizing
property for the parent container.The long answer:
Consider this:
There are two values in
box-sizing
that you should know aboutcontent-box
border-box
I usually start any CSS sheet with the following to avoid such issues
There are many frameworks that reset more of the default properties such as normalize.css but I often don’t have the need to use them.
I set up a demo below. There are two
div
elements. There is also a media query.Both elements have the same fixed
width
inpx
. The only difference is the value for thebox-sizing
The first is set to
border-box
and the second is set tocontent-box
Notice how they render with different sizes even when the
width
for both is the same?