html - 如何在 CSS 中将左侧 float 元素居中用于手机 View ?

标签 html css twitter-bootstrap jquery-mobile

我有一个网页在台式电脑上看起来不错,但在手机上看起来不如网格上的元素向左浮动,但我希望它们显示在中间。是否有一个简单的“@media only screen”代码我可以添加或任何我可以更改到我的下面的 CSS 以便它以移动设备为中心?此外,div class="col-xs-12 col-sm-6 col-lg-6" 这是一个 Image Example: Desktop vs Mobile View

您还可以在 - http://www.helpme.ae/ 查看一个实例。

.GRID
width:170px;
height:235px;
background:#f4f4f4;
border:1px solid #dedede;
padding:4px;
border-radius:4px;
text-align: center;
float:left;
margin:9px;
margin-bottom:20px;
position:relative

.XOX
display: block;
margin-bottom: 3px;
margin-top: 0px; 
overflow:hidden

.widget-container
{
text-align:left
}

.widget-container ul { padding:0; margin:0; list-style-type:none }
.widget-container ul li { margin-bottom:6px; }

最佳答案

使用这个 CSS:

@media (max-width: 991px) {
  .latest-posted-tasks-big {
    text-align: center;
  }
  .latest-posted-tasks-big > * {
    text-align: initial;
  }
  .latest-posted-tasks-big > .grid_task {
    display: inline-block;
    float: none;
  }
}

关于html - 如何在 CSS 中将左侧 float 元素居中用于手机 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34669061/

相关文章:

javascript - jQuery 和自动调整文本区域大小的问题

javascript - 单击动画 div 并制作全宽 jQuery

jquery - 选择具有相同类的所有元素

jquery - 弹出窗口 : close pop over when clicked outside of pop over

javascript - Bootstrap 弹出框 : open one popover with 2 different links

javascript - 如何在变量中收集HTML页面的所有脚本标签

javascript - jQuery + 测试元素值(扩展)

html - div 的定位仅在 Firefox 中发生变化

css - Bootstrap + 简单表单复选框网格

javascript - 添加点击监听器以在循环中列出项目