您可以使用:before和:after伪元素来设置这两条特定垂直线的样式:
fieldset {
border:1px solid gray;
}
legend {
padding: 0.2em 0.5em;
color: gray;
font-size: 90%;
position: relative;
margin-left: auto;
margin-right: auto;
}
legend:before {
position: absolute;
content: '';
height: 8px;
border-left: 1px solid gray;
left: 0px;
top: 7px;
}
legend:after {
position: absolute;
content: '';
height: 8px;
border-right: 1px solid gray;
right: 0px;
top: 7px;
}Run Code Online (Sandbox Code Playgroud)
<form>
<fieldset>
<legend>Subscription info</legend>
<label for="name">Username:</label>
<input type="text" name="name" id="name" />
<br />
<label for="mail">E-mail:</label>
<input type="text" name="mail" id="mail" />
<br />
<label for="address">Address:</label>
<input type="text" name="address" id="address" size="40" />
</fieldset>
</form>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8501 次 |
| 最近记录: |