twitter-bootstrap 如何仅将样式应用于引导程序中的特定屏幕类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25419608/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to apply style only to particular screen type in bootstrap
提问by Sathish Manohar
I have a general style definition as
我有一个通用的样式定义为
.main-site-nav li a {
padding-left: 0;
}
Now want to apply a different style only for .main-site-nav li ain extra small screens (xs) only as follows.
现在只想.main-site-nav li a在超小屏幕 (xs) 中应用不同的样式,如下所示。
/* xs screens only */
.main-site-nav li a {
padding-left: 15;
}
How can I do it?
我该怎么做?
Thanks
谢谢
回答by 4dgaurav
The selectors used in BS3 (v3.2.0), if you want to stay consistent:
BS3 (v3.2.0) 中使用的选择器,如果你想保持一致:
@media(max-width:767px){
.main-site-nav li a {
padding-left: 15;
}
}
This will take care of your xs screen
这将照顾您的 xs 屏幕
回答by Suresh Ponnukalai
Use media queries like below. I have assumed your small screen resolution is 500px.
使用如下媒体查询。我假设你的小屏幕分辨率是 500px。
@media all and (max-width: 500px)
{
.main-site-nav li a {
padding-left: 15;
}
}
You can also specify min-widthand max-widthlike below.
您也可以在下面指定min-width和max-width喜欢。
@media all and (max-width: 500px) and (min-width: 380px)
{
.main-site-nav li a {
padding-left: 15;
}
}

