0
A
回答
5
可以使用HTML fieldset
這與legend
。這裏所有的CSS東西都是可選的。
另外legend
的before
和after
可用於設置其文本附近的空間。請注意,這樣你不會重疊你的背景。
演示:
fieldset {
display: inline-block;
border-radius: 25px;
color: #4b94ec;
font-size: 25px;
padding-left: 30px;
padding-right: 30px;
padding-bottom: 20px;
border: 3px solid #848fa9;
}
legend {
display: inline-block;
text-transform: uppercase;
text-align: center;
}
legend:before,
legend:after {
content: "";
display: inline-block;
width: 10px;
}
fieldset div {
color: #b53f56;
}
<fieldset>
<legend>Reliable</legend>
<div>More text here</div>
<div>More text here</div>
<div>More text here</div>
<div>More text here</div>
<div>More text here</div>
<div>More text here</div>
<div>More text here</div>
<div>More text here</div>
<div>More text here</div>
</fieldset>
0
您可以通過單詞「可靠」的背景顏色設置到div的背景顏色相同做到這一點。然後使用負邊距頂部,您可以定位文本,使其位於頂部邊框。以下是我放在一起的一個簡單例子。
https://codepen.io/anon/pen/yXWrbe
HTML
<div id="blah">
<h4>RELIABLE</h4>
<p>More Text Here</p>
<p>More Text Here</p>
<p>More Text Here</p>
<p>More Text Here</p>
<p>More Text Here</p>
</div>
CSS
#blah {
width: 180px;
margin-top: 20px;
border: 3px solid green;
border-radius: 10px;
text-align: center;
font-family: arial;
}
#blah h4 {
width: 100px;
background: #fff;
margin: -10px auto 0 auto;
color: blue;
}
#blah p {
color: red;
}
1
下面是一個例子。要指出的關鍵是.title
範圍,其上設置了position: relative
和top
以將其從其原本位於其中的位置向上移動,並且background-color
阻止邊框通過文本。
.container {
border: 3px solid blue;
border-radius: 30px;
width: 180px;
padding: 0 30px;
margin-top: 50px;
}
.title {
color: blue;
font-size: 35px;
background-color: white;
padding: 10px;
position: relative;
top: -20px;
}
p {
color: red;
font-size: 25px;
}
<div class="container">
<span class="title">Reliable</span>
<p>More text here. More text here. More text here. More text here. More text here. More text here. More text here. More text here. More text here. More text here. More text here. </p>
</div>
0
你也可以看看柔性特性和利潤率上進行復位的事情....
.mebox {
display: inline-block;
border: solid turquoise;
padding: 0 1em 1em;
margin: 1em;
border-radius: 1em;
border-top: none;
}
.mebox h4 {
display: flex;
text-align: center;
justify-content: center;
margin: 0 -2.1em 0;
line-height: 0;
}
h4:before,
h4:after {
content: '';
flex: 1;
height: 1em;
border-top: solid turquoise;
border-radius: 0 1em;
margin: auto 1em;
}
h4:before {
border-radius: 1em 0;
}
<div class="mebox">
<h4>RELIABLE</h4>
<p>More Text Here</p>
<p>More Text Here</p>
<p>More Text Here</p>
<p>More Text Here</p>
<p>More Text Here</p>
</div>
<div class="mebox">
<h4>RELIABLE</h4>
<p>More Text Here More Text Here</p>
<p>More Text Here</p>
<p>More Text Here</p>
<p>More Text Here</p>
<p>More Text Here</p>
</div>
相關問題
- 1. Windows 8 C#/ XAML - 在文本塊文本週圍創建邊框
- 2. While()Loop在文本週圍創建星號邊框?
- 3. 文本框周圍的部分邊框
- 4. 爲JEditorPane文本框創建左邊距
- 5. 相對於文本創建邊框?
- 6. 如何在圖像周圍創建邊框而不是在JLabel周圍創建邊框?
- 7. SVG文本週圍的矩形邊框
- 8. 如何在多個文本框中創建底線邊框
- 9. 如何用虛線邊框或雙線邊框創建文本框
- 10. CSS樣式覆蓋默認文本框邊框來創建隱形邊框?
- 11. 創建文本框,通過JS
- 12. 如何在不超過該文本的文本之下創建邊框?
- 13. 如何使用傾斜邊框創建文本框和標籤?
- 14. 使用集成文本框創建邊框樣式
- 15. 創建無邊框文本框(鈦工作室Android)
- 16. 創建邊框2周的div
- 17. 目標C:如何在照片周圍創建邊框效果
- 18. 如何在內容周圍創建動態托架邊框?
- 19. 使用8張圖像在UIImageView周圍創建邊框
- 20. 你如何在一個元素周圍創建一個邊框?
- 21. 使用CSS在圖像周圍創建圓形邊框
- 22. 在你的D3圖形周圍創建一個邊框
- 23. 如何在內容周圍創建邊框
- 24. 如何在輸入按鈕周圍創建邊框?
- 25. 如何在整個圖層列表周圍創建邊框?
- 26. 如何在JLabel周圍創建一個不可見邊框? (JAVA)
- 27. 在鏈接周圍創建方形邊框
- 28. 在具有相同值的單元格周圍創建邊框
- 29. 在所有UIButtons周圍創建單個邊框Xamarin
- 30. 在光流路徑周圍創建邊界框
可能的重複:[文本下的邊框,但不是通過文本](https://stackoverflow.com/questions/12332537/border-under-text-but-not-through-the-text)? – Ryan