[英]Styling website for different screen sizes with Bootstrap 3
I am using the following method to style my website for different screen sizes. 我使用以下方法为我的网站设置不同屏幕尺寸的样式。
<div id="sidebar" class="col-md-3 hidden-xs hidden-sm">
<!-- Inner Classes and Stuff -->
<!-- IMPORTANT: Div auto-inserted by Typo3 -->
</div> <!-- sidebar -->
<div id="sidebar_mobile" class="col-xs-12 hidden-md hidden-lg">
<!-- Inner Classes and Stuff -->
<!-- IMPORTANT: Div auto-inserted by Typo3 -->
</div> <!-- sidebar -->
I then define different styles that I need for #sidebar and #sidebar_mobile in my CSS. 然后我在CSS中定义了#sidebar和#sidebar_mobile所需的不同样式。 This leads to two problems: 这导致两个问题:
I would like to know if there is a better way of going about things in this case. 我想知道在这种情况下是否有更好的办法。 What would be a better solution 什么是更好的解决方案
Why are you using two different wrappers for mobile/desktop instead using CSS to style them individually: 为什么你使用两个不同的移动/桌面包装器而不是使用CSS来单独设置它们:
<div id="sidebar" class="col-sm-12 col-md-3">
<!-- Inner Classes and Stuff -->
<!-- IMPORTANT: Div auto-inserted by Typo3 -->
</div>
#sidebar {
/* Mobile/Tablet styles (xs, sm) */
}
@media (min-width: 991px) {
#sidebar {
/* Tablet/Desktop styles (md, lg) */
}
}
This is the mobile first variant. 这是移动的第一个变种。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.