[英]Bootstrap - How to ensure white space on far left and far right on mobile
Can anyone tell me how to ensure I get white space/margin on the left hand side and right hand side when the page is viewed on a mobile phone? 谁能告诉我在手机上查看网页时如何确保左侧和右侧留有空白?
My CSS is: 我的CSS是:
#maxCostSlider {
max-width:304px;
width:304px;
padding:0px;
margin-left:-6px;
}
@media (max-width: 480px) {
#maxCostSlider,#sliderScale {
margin-left: 20px;
margin-right: 20px;
}
}
HTML is: HTML是:
<div class="container-fluid">
<div class="row">
<div class="col-md-offset-4 col-md-4">
<img id="sliderScale" src="/assets/img/price slider 1.png" alt="" class="img-responsive" />
</div>
</div>
<div class="row text-center">
<div class="col-md-offset-4 col-md-4">
<input id="maxCost" data-slider-id='maxCostSlider' type="text" data-slider-min="0" data-slider-max="100" data-slider-step="10" data-slider-value="40" />
</div>
</div>
</div>
This all looks good on a desktop and an iPad but when viewed on an iPhone the bootstrap-slider widget spans the entire width of the device. 这一切在台式机和iPad上看起来都不错,但是在iPhone上查看时,bootstrap-slider小部件会覆盖设备的整个宽度。 I would like to ensure there is always a margin of at least 20px either side of the two rows.
我想确保两行两侧的边距始终至少为20px。 Ideally the bootstrap-slider would scale to fit.
理想情况下,自举滑块可以缩放以适合自己。
Hard to tell without know the exact slider component you are using, but adding this to your CSS should work: 不知道您正在使用的确切滑块组件很难说,但是将其添加到CSS应该可以:
#maxCostSlider {
margin-left: 20px;
margin-right: 20px;
}
However if you only want that to happen at mobile width, wrap it in a media query: 但是,如果只希望在移动宽度上发生这种情况,请将其包装在媒体查询中:
@media (max-width: 480px) {
#maxCostSlider {
margin-left: 20px;
margin-right: 20px;
}
}
For small device(sm) and extra small device (xs) you can call them separately. 对于小型设备(sm)和超小型设备(xs),您可以分别调用它们。
<div class="col-sm-offset-1 col-xs-offset-1 col-md-offset-4 col-md-4"></div>
And another way you can do this by css. 还有另一种方法可以通过CSS执行此操作。
@media (min-width: 240px) and (max-width: 480px) {
#max-cost {
padding-left: 20px;
padding-right: 20px;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.