I am writing a media query for a web-page and managed to write media queries for 768 and below. But it doesn't work properly. I want to capture the portrait views of most of the mobiles( iphone4, iphone5,iphone3,asus galaxy 7,samsung galaxy sII, samsung galaxy s3 ) which is 320px. The webpage I created was working for 768px and above but not working for media query below 768px
@media (min-width:481px) and (max-width:768px) {
.navbar-brand{
margin-left: 80px;
}}
@media (min-width: 768px){
.navbar-brand{
margin-left: 100px;
}
@media (min-width: 991px){
.navbar-brand{
margin-left: 150px;
}}
Here in this example margin left property working very well on min-width: 768px and min-width:991px but not working on @media (min-width:481px) and (max-width:768px).
You are missing a curly bracket to close of your media query for min-width: 768px
. Here's the final code with formatting to more easily see it.
@media (min-width:481px) and (max-width:768px) {
.navbar-brand {
margin-left: 80px;
}
}
@media (min-width: 768px) {
.navbar-brand {
margin-left: 100px;
}
}
@media (min-width: 991px) {
.navbar-brand{
margin-left: 150px;
}
}
For capturing screensizes that is 320px with a specific margin you can either remove (min-width:481px) and
from your first media query if the same styling should apply or add a media query specific for that case:
@media (max-width: 320px) {
.classname {
enter some code here
}
}
Please take a look and confirm below media queries with updated code.
@media only screen and (min-width: 768px) {
.navbar-brand {
margin-left: 100px;
}
}
@media only screen (min-width: 481px) and (max-width:767px) {
.navbar-brand {
margin-left: 80px;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.