2

500px我以为我只为之间的屏幕设置了一条规则,1024px甚至在屏幕尺寸超过1024px.

这是CSS。该.red样式正确应用于小于480px. 只是黄色适用于所有屏幕,即使max-width1024px.

.buy {
    border: 1px solid #ABABAB;
    color: #333333;
    display: block;
    font-family: calibri,helvetica,sans-serif;
    font-size: 12px;
    font-weight: bold;
    height: 25px;
    line-height: 25px;
    margin: auto;
    text-align: center;
    text-decoration: none;
    width: 70px;
}

@media only screen and (max-width: 480px) {
    .buy {
        color: red;
    }
}

@media screen and (max-width: 1024px) and (min-width: 500px) {
    .buy {
        color: yellow;
    }
}
4

1 回答 1

2

你忘了only

@media only screen and (min-width: 500px) and (max-width: 1024px) {
   .buy {
     color: yellow;
   }
}
于 2012-08-16T15:02:33.990 回答