我有一个简单的代码:
<div class="delem"><label class="required" for="last_name">Full Name :</label><input id="fullname" type="text" name="fullname" value="" class="fullsize" required=""></div>
<div class="delem"><label class="required" for="identity_number">Personal ID Number:</label><input id="identity_number" type="text" name="_identityNumber" value="" class="fullsize" required=""></div>
我想要更改&#34;个人ID号码&#34;与css。
答案 0 :(得分:0)
将标签的字体大小设置为0,以隐藏文本。将标签的新文本放在:: before或:: after伪元素中,并将其字体大小设置为标签大小最初的大小。 (假设1rem在这里。)
label[for="identity_number"] {
font-size: 0
}
label[for="identity_number"]::after {
font-size: 1rem;
content: 'Some other number: ';
}
<div class="delem"><label class="required" for="identity_number">Personal ID Number:</label><input id="identity_number" type="text" name="_identityNumber" value="" class="fullsize" required=""></div>
答案 1 :(得分:0)
.delem:nth-child(2) label {
position:relative}
.delem:nth-child(2) label::before {
position:absolute;
background:#fff;
width:136px;
height:21px;
content:"Place your Text:"}