gpt4 book ai didi

css - 使用 CSS 对齐最后一行文本

转载 作者:行者123 更新时间:2023-11-28 10:56:50 25 4
gpt4 key购买 nike

我有一个 CSS 帮助程序类,旨在强制“文本”的最后一行(或在预期用途中,内联 block div)与其余行一样对齐。

这是我得到的代码:

.justify-all-lines
{
text-align: justify;
/* IE-only properties that make the :after below unnecessary (we need this because IE 6/7 don't support :after, though) but if they both apply it'll be fine */
-ms-text-justify: distribute-all-lines;
text-justify: distribute-all-lines;
}

.justify-all-lines > *:last-child:after
{
display: inline-block;
width: 100%;
content: 'hello';
}

.blocky
{
display: inline-block;
/* Make inline block work in IE 6/7 */
zoom: 1;
*display: inline;
}

这是为了像这样使用:

<div class="justify-all-lines">
<div class="blocky">There is stuff in here.</div>
<div class="blocky">There is stuff in here.</div>
<div class="blocky">There is stuff in here.</div>
<div class="blocky">There is stuff in here.</div>
<div class="blocky">There is stuff in here.</div>
<div class="blocky">There is stuff in here.</div>
<div class="blocky">There is stuff in here.</div>
<div class="blocky">There is stuff in here.</div>
<div class="blocky">There is stuff in here.</div>
<div class="blocky">There is stuff in here.</div>
</div>

但是,我看到“hello”出现在最后一个“ block 状”div 内部,而不是在最后一个“ block 状”div 之后。我做错了什么?

最佳答案

工作解决方案:

.justify-all-lines
{
/* This element will need layout for the text-justify
* to take effect in IE7 (and possibly previous versions);
* this will force it, for more info Google "hasLayout in IE"
*/
overflow: hidden;
text-align: justify;

/* For IE6 to IE7 since they don't support :after */
-ms-text-justify: distribute-all-lines; /* IE8+ */
text-justify: distribute-all-lines; /* IE5+ */
}

.justify-all-lines:after
{
/*
* We don't need IE6 and IE7 inline-block hack support here
* since they don't support :after anyways (the text-justify
* properties for them are above)... IE8 and above have native
* inline-block support so for IE8+, both the text-justify and
* :after will take effect but it doesn't have any negative
* effects since this element is invisible
*/
display: inline-block;
width: 100%;
content: '.';
font-size: 0;
height: 0;
line-height: 0;
visibility: hidden;
}

关于css - 使用 CSS 对齐最后一行文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6950513/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com