alignment - 文本对齐 : justify + left

标签 alignment css justify

我有这样的代码: 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/

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

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

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

最佳答案

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

关于alignment - 文本对齐 : justify + left,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27461735/

相关文章:

nlp - 如何解释对齐工具 fast_align 的对齐分数?

css - 在 3 列布局中定位/对齐中间元素

html - 不同浏览器 HTML 对齐

html - 带侧边栏的棘手粘性页脚

html - 如何将 DIV 缩放到全宽?

css - 为什么显示: -ms-flex; -ms-justify-content: center; not work in IE10?

Qt:QTreeView:标题上的中心图标

jquery - 页面在刷新/重新加载时移动?

wordpress - IE Internet Explorer 和 Android 上的文本对齐对齐错误

html - 在 html 中使用对齐时,如何在两个单词的名称中保留一个小空间?