我有一個CSS幫助程序類,用於強制最後一行「文本」(或用於預期用法,內聯塊div)成爲對齊對齊以及其餘的人。使用CSS調整文本的最後一行
下面是我得到了代碼:
.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>
但是,我看到了「你好」顯示裏面的最後一個「塊狀」而不是在最後的「塊狀」div之後。我究竟做錯了什麼?
'.justify,全行> *:最後的孩子:後{/ *的東西對IE6/7 * /}'是奇數。 IE6不支持'>',IE6/7都不支持':last-child'或':after'。 – thirtydot
您目前正在測試哪些瀏覽器?你可以做一個[jsFiddle](http://jsfiddle.net/)演示顯示問題? – thirtydot
@thirtydot我使用無點(http://www.dotlesscss.org/),這只是一個複製和粘貼異常,因爲我爲了這篇文章的目的將一個mixin轉換爲內聯CSS。想象更多的人會比LESS更熟悉純CSS。我會解決它。 ;) –