【问题标题】:text-align: justify + left文本对齐:对齐+左
【发布时间】:2015-02-12 05:34:16
【问题描述】:

我有这样的代码: HTML:

<div id="container">
    <div>some</div>
    <div>text</div>
    <div>here</div>
    <div>...</div>
</div>
<div id="container">
    <div>some</div>
    <div>text</div>
</div>

和 CSS:

#container {
    text-align: justify;
}

#container:after {
    content: "";
    display: inline-block;
    width: 100%;
}

#container > div {
    text-align: left;
    display: inline-block;
    width: 100px;
    background-color: #333;
    color: white;
}

http://jsfiddle.net/1odgx6vq/

我需要对齐块,因为它们具有固定宽度,但我需要在第二个容器中“左对齐”。有没有办法做到这一点? 感谢您的回复。

编辑: 我尝试通过添加具有继承背景的元素来使用 JS 修复它,当我在 HTML 代码中手动添加它时可以使用,但是使用 JS 它不会重新对齐,演示:

http://jsfiddle.net/1odgx6vq/1/

【问题讨论】:

    标签: alignment css justify


    【解决方案1】:

    通过在之前和在javascript添加的元素之后添加一个空格来修复

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-13
      • 1970-01-01
      • 2012-02-24
      • 2019-10-01
      • 2015-10-07
      • 1970-01-01
      • 1970-01-01
      • 2016-09-24
      相关资源
      最近更新 更多