【发布时间】:2019-09-06 02:42:27
【问题描述】:
我想仅对手机和平板电脑等小屏幕应用 margin-top: 45px。以下是我的代码:
@x-large: ~"only screen and (min-width: 1201px)";
@large: ~"only screen and (max-width : 1200px)";
@medium: ~"only screen and (max-width : 992px)";
@small: ~"only screen and (max-width : 480px)";
@x-small: ~"only screen and (max-width : 320px)";
#myPanel {
@media @small {
margin-top: 45px !important;
}
@media @x-small {
margin-top: 45px !important;
}
@media @tablet {
margin-top: 45px !important;
}
@media @x-large {
margin-top: 0px;
}
@media @large {
margin-top: 0px;
}
}
问题是当我切换到桌面大小时,也会应用样式。我必须使用!important,否则它不适用于小屏幕。
【问题讨论】:
标签: css