css – 缩进包装文本

前端之家收集整理的这篇文章主要介绍了css – 缩进包装文本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我正在模拟一个表格布局,里面有一个div和一对夫妇。我想要右边的范围缩进任何包裹的文字。我已经尝试了一些事情,不能让它工作。任何帮助将不胜感激。

jsFiddle:http://jsfiddle.net/2Wbuv/

HTML

<div class="display-element">
    <span class="display-label">Field 1</span>
    <span class="display-field">This is my string of data,some times it is pretty long.  Sometimes it is not.  This one is.</span>
</div>
<div class="display-element">
    <span class="display-label">Field 2</span>
    <span class="display-field">This is another string of data.</span>
</div>

CSS

.display-element        {}

.display-label          {display: inline-block;
                         width: 100px;
                         padding-left: 5px;}

.display-field          {display: inline;}

解决方法

检查出来: http://jsfiddle.net/2Wbuv/2/
.display-element {
}

.display-label {
  display: inline-block;
  width: 100px;
  padding-left: 5px;
}

.display-field {
  display: inline-block;
  padding-left: 50px;
  text-indent: -50px;
  vertical-align: top;
  width: 200px; /* for testing purposes only */
}
<div class="display-element">
  <span class="display-label">Field 1</span>
  <span class="display-field">This is my string of data,some times it is pretty long.  Sometimes it is not.  This one is.</span>
</div>
<div class="display-element">
  <span class="display-label">Field 2</span>
  <span class="display-field">This is another string of data.</span>
</div>
原文链接:https://www.f2er.com/css/218267.html

猜你在找的CSS相关文章