【问题标题】:How to let the div [duplicate]如何让 div [重复]
【发布时间】:2018-09-26 05:05:16
【问题描述】:

我使用下面的代码让con-order 宽度为 80%:

.con-order {

    height: 100%;
    width: 80%;
    overflow: hidden;

html代码如下:

<div class="con-order">
    <div class="alert">
      <Alert type="warning" show-icon closable>
    ...

下面这样,我要内容移动中心。

我尝试使用text-align: center;,但内容变得奇怪。

变成这样,我不要这样:

我希望所有内容都移到中心,而不是所有内容都居中。

【问题讨论】:

标签: css less


【解决方案1】:

这对你来说很好。

.con-order {
    height: 100%;
    width: 80%;
    overflow: hidden;
    margin: 0 auto;

【讨论】:

    【解决方案2】:

    margin: 0 auto 是 div 的实际居中位置。

    它将使元素水平居中,并且无需设置特定宽度即可工作。

    .con-order {
      height: 100%;
      width: 80%;
      overflow: hidden;
      margin: 0 auto;
    }
    

    【讨论】:

      猜你喜欢
      • 2018-01-29
      • 2018-09-29
      • 2018-11-18
      • 2020-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-27
      • 2022-01-14
      相关资源
      最近更新 更多