所以我正在模拟一个表格布局,里面有一个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>