Ell*_*ris 2 html css fieldset legend
我疯了试图找出如何使这项工作。我希望图例在边界之外。如何在保留图例标签的同时实现此目的?如您在下面看到的,我尝试使用span,但是它不起作用。
body {
background-color: #996600;
color: black;
}
fieldset {
border: 10px solid #ffffff;
border-radius: 10px;
background-color: #999900;
box-shadow: 10px 10px 5px #888888;
position: relative;
}
legend {
font-size: 20px;
float: left;
}
legend span {
top: 0px;
left: 0px;
position: absolute;
}
input[type=text] {
border: 2px solid black;
border-radius: 10px;
background-color: #cccc80;
}
input[type=button] {
background-color: #996600;
border: 2px solid black;
border-radius: 5px;
color: #c9ae78;
font-weight: bolder;
}
p {
font-size: 12px;
font-style: italic;
}Run Code Online (Sandbox Code Playgroud)
<form method="post" id="contactForm" action="#">
<fieldset>
<legend><span>Newsletter Signup</span>
</legend>
<p>To sign up for our fabulous campaign of useless information that you will never, ever read, please submit your email address here.</p>
<label for="email" id="emailLabel">Email</label>
<input type="text" id="email" />
<input type="button" name="submit" value="Submit" id="submitButton" />
</fieldset>
</form>Run Code Online (Sandbox Code Playgroud)
使用position: absolute你的传说,并添加margin-top您fiedset来弥补这一转变:
body {
background-color: #996600;
color: black;
}
fieldset {
border: 10px solid #ffffff;
border-radius: 10px;
background-color: #999900;
box-shadow: 10px 10px 5px #888888;
position: relative;
margin-top: 35px;
}
fieldset legend {
position: absolute;
top: -35px;
left: 10px;
font-size: 20px;
}
input[type=text] {
border: 2px solid black;
border-radius: 10px;
background-color: #cccc80;
}
input[type=button] {
background-color: #996600;
border: 2px solid black;
border-radius: 5px;
color: #c9ae78;
font-weight: bolder;
}
p {
font-size: 12px;
font-style: italic;
}Run Code Online (Sandbox Code Playgroud)
<form method="post" id="contactForm" action="#">
<fieldset>
<legend>Newsletter Signup</legend>
<p>To sign up for our fabulous campaign of useless information that you will never, ever read, please submit your email address here.</p>
<label for="email" id="emailLabel">Email</label>
<input type="text" id="email" />
<input type="button" name="submit" value="Submit" id="submitButton" />
</fieldset>
</form>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2502 次 |
| 最近记录: |