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. 为JEditorPane文本框创建左边距
- 2. 如何在图像周围创建边框而不是在JLabel周围创建边框?
- 3. CSS样式覆盖默认文本框边框来创建隐形边框?
- 4. 如何在不超过该文本的文本之下创建边框?
- 5. 使用集成文本框创建边框样式
- 6. 在光流路径周围创建边界框
- 7. 在你的D3图形周围创建一个边框
- 8. 在所有UIButtons周围创建单个边框Xamarin
- 9. 在具有相同值的单元格周围创建边框
- 10. 如何在输入按钮周围创建边框?
- 11. 如何在JLabel周围创建一个不可见边框? (JAVA)
- 12. 你如何在一个元素周围创建一个边框?
- 13. 如何在内容周围创建动态托架边框?
- 14. 在ListView中创建边框
- 15. 围绕文本创建白框GD-Lib
- 16. 使用2D阵列在java中创建文本边框
- 17. QLabel在文字周围添加“边框”
- 18. 围绕文本范围的边框
- 19. OpenGL混合创建纹理周围的白色边框
- 20. onclick创建文本框
- 21. 动态创建文本框
- 22. 动态创建文本框
- 23. 动态创建文本框
- 24. 如何为TextBlock中的文本创建边框?
- 25. 如何创建自定义边框到文本
- 26. 使用CSS创建流畅的文本边框
- 27. 无法创建表边框
- 28. 为uitableview创建边框
- 29. 创建边框对象
- 30. unity3d创建表格边框
可能的重复:[文本下的边框,但不是通过文本](https://stackoverflow.com/questions/12332537/border-under-text-but-not-through-the-text)? – Ryan