html - 将 4 个 DIV 对齐到页面的中心

标签 html css

我有一页内容,并排有 4 个 div。

目前 div 粘在左边。

我试图将 div 包裹在容器中并文本对齐该中心,但它不起作用。

这是我正在使用的代码,我已经删除了一些图片 URL 等

#downloads {
  text-align: center!important;
}

.dl-buttons {
  text-align: center!important;
}

- I know this is duplicate but was testing .windows a {
  width: 190px;
  height: 190px;
  display: inline-block;
  float: left;
}
<div id="downloads">
  <div class="row dl-buttons">
    <div class="col-3 col-6-sx windows">
      <a class="bt1" href="#"></a>
    </div>
    <div class="col-3 col-6-sx mac">
      <a class="bt1" href="#"></a>
    </div>
    <div class="col-3 col-6-sx android">
      <a class="bt1" href="#"></a>
    </div>
    <div class="col-3 col-6-sx ios">
      <a class="bt1" href="#"></a>
    </div>
  </div>
</div>

  • 所有其他类/mac/android/ios都一样

最佳答案

.dl-buttons{
    width: 100%;
    text-align: center;
}

.dl-buttons > div {
    width: auto;
    display: inline-block;
}

关于html - 将 4 个 DIV 对齐到页面的中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44259830/

相关文章:

javascript - Bootstrap 自定义验证未在提交表单时显示特定字段

html - Css sibling (~) 选择器不适用于选中的属性

javascript - 如何使用 JavaScript 或 jQuery 更改另一个页面上元素的样式?

jquery - chrome 自动完成中断样式选择

html - Chrome 中 <dl> 缺少 1 行像素

css - iPad Safari 浏览器中的样式问题,设置高度宽度不起作用

python - 处理带有空格的 css 类名

php - 如何在 codeigniter 中水平显示我的元素

php - 在网格中平铺缩略图

html - Socket.IO - 要求未定义