在换行时,缩进DIV文本的最佳方式是什么? [英] What is the best way to indent text in a DIV when it wraps?
本文介绍了在换行时,缩进DIV文本的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我的原始文本如下所示:
Lorem ipsum dolor sit amet,
consectetur adipisicing
elit,sed do eiusmod
tempor incididunt
相反,我希望它看起来像这样:
Lorem ipsum dolor sit amet,
consectetur adipisicing
elit,sed do eiusmod
tempor incididunt
什么是如果我不知道DIV的大小,最好的办法是做到这一点?如果我知道这个尺寸,最好的方法是什么?
谢谢!
解决方案div {
padding-left:2em;
text-indent:-2em;
}
So I have a DIV that contains some dynamic text. Let's say I know the text and font-size but I don't know the size of the DIV. I'd like the display of the text in the DIV to be intelligent enough to show indentation when text wraps.
Say my original text looked something like this:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididuntInstead, I want it to look like this:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididuntWhat's the best way to do this if I don't know the size of the DIV a priori? And what's the best way to do it if I do know the size?
Thanks!
解决方案If I understand what you're asking for, this works for me:
div { padding-left: 2em; text-indent: -2em; }
这篇关于在换行时,缩进DIV文本的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文