[英]How to indent text without using margin or padding in html code?
Text inside the p
should start in the same line with the h3
element just like in the image bellow, but without using margin
or padding
. p
内的文本应与h3
元素在同一行中开始,就像在图像波纹管中一样,但不要使用margin
或padding
。 Any solution for this? 有什么解决办法吗?
.inner h1, h3{ display: inline-block; vertical-align: text-bottom; }
<div class="inner"> <h1>1.</h1> <h3>Download app</h3> <h3>Free</h3> <p> Some text here Some text here Some text here</p> <p> Some text here Some text here Some text here</p> </div>
You may simply use ol
list for this : 您可以为此简单地使用
ol
list:
<ol> <li> <h3>Download app<br/>Free</h3> <p> Some text here Some text here Some text here<br/>Some text here Some text here Some text here</p> </li> </ol>
Give text-indent
to p
tag like this: 给
p
标签加上text-indent
,如下所示:
.inner p {
text-indent: 23px;
}
.inner h1, h3{ display: inline-block; vertical-align: middle; } .inner p { text-indent: 23px; }
<div class="inner"> <h1>1.</h1><h3> Download app</h3> <h3>Free</h3> <p> Some text here Some text here Some text here</p> <p> Some text here Some text here Some text here</p> </div>
Using flex-box
you can "stretch" the h1
to take the entire height of the right side. 使用
flex-box
可以“拉伸” h1
以占据右侧的整个高度。
.inner { display: flex; } h1, h3 { margin: 0; }
<div class="inner"> <h1>1.</h1> <div> <h3>Download app Free</h3> <p> Some text here Some text here Some text here</p> <p> Some text here Some text here Some text here</p> </div> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.