[英]How to indent text without using margin or padding in html code?
p
內的文本應與h3
元素在同一行中開始,就像在圖像波紋管中一樣,但不要使用margin
或padding
。 有什么解決辦法嗎?
.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>
您可以為此簡單地使用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>
給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>
使用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.