Currently working on an HTML/CSS/JS project.
Within my <head>
section, there's a viewport <meta>
tag:
<meta name="viewport" content="width=device-width, initial-scale=1" />
Encountering unexpected behavior with two media queries in my CSS file. Using max-width
, but changes in UI are occurring at different viewport sizes than intended as explained in the comments below:
/* currently happening between 320px and 561px */
@media only screen and (max-width: 700px) {
.sidebar {
border: 1px solid orange;
width: 100%;
height: auto;
position: relative;
display: flex;
}
main {
margin-left: 0;
}
}
/* currently taking effect when screen size is <= 320px */
@media only screen and (max-width: 400px) {
.sidebar {
border: 1px solid green;
display: flex;
flex-direction: column;
text-align: center;
}
}
Seeking insight on why this discrepancy is occurring and how to ensure changes align with the intended max-width
values of 700px and 400px, respectively?