I wrote a piece of CSS code to smoothly switch the width of the layout of my site depending on the width of the user's screen. If the user has less than the available state of the screen, the breadth of the layout increases to fill most of the window and leave less free space, and if he has more space, the layout is reduced to maintain an attractive appearance.
I use the following code to achieve this:
#bg{
background:-webkit-linear-gradient(90deg, #0f0f0f 0%,#222222 400px);
background:-moz-linear-gradient(90deg, #0f0f0f 0%,#222222 400px);
background:-o-linear-gradient(90deg, #0f0f0f 0%,#222222 400px);
background:linear-gradient(90deg, #0f0f0f 0%,#222222 400px);
margin-left:auto;
margin-right:auto;
margin-bottom:1.6rem;
border-width:0 0.1rem 0.1rem 0.1rem;
border-style:solid;
border-color:#303030 #101010 #000;
border-radius:0.8rem;
min-width:94.2rem
}
@media (min-width: 70rem){
#bg{
border-radius:4px;
border-radius:0.4rem;
width:90%
}
}
@media (min-width: 91rem){
#bg{
width:80%
}
}
@media (min-width: 112rem){
#bg{
width:70%
}
}
This works great in Firefox 30, however Google Chrome always displays an element with a width of 70%.
Earlier, I also used max-width in queries, in which case Chrome did the opposite; it will always display the element 90%, no matter how I resize the browser window.
SASS. ? ?
- .