I have a @media
that is not working for some reason.
When I resize my browser under 768px, I can see the CSS rules popup in the browser but they have no effect. The Buttons still have 245px width.
CSS:
#product-tabs button{
width: 100%;
min-width: 245px;
border: 1px solid #777;
background: #fff;
color: #444444;
border-bottom: 0;
}
#product-tabs button.active {
background: #288d95;
border: 1px solid #288d95;
color: #fff;
}
@media (max-width: 768px){
#product-tabs button{
max-width: 180px;
}
}
UPDATE
i found the problem, min-width CANT be higher than max-width
i change the css to this
@media (max-width: 768px){
#product-tabs button{
max-width: 180px;
min-width: 100%;
}
}
2
Answers
This is because CSS rules inside
@media
are not treated with more specificity than CSS outside a@media
block.Therefore, the correct solution is to move the @media query at the end of the CSS:
max-width
andmin-width
are 2 different CSS properties and one can not override other. In this case, I think you need tounset
themin-width
first using the media query and then use themax-width
rule so that it can take effect.