我试图将文本置于复选框中间,但文本位于顶部。
我会在这里留下完整的代码
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<head>
<style>
input {
display: inline-block;
vertical-align: top;
padding-left: 25px;
position: relative;
}
input {
position: absolute;
left: 0;
top: 0;
}
</style>
</head>
<body>
<input class="w3-check" type="checkbox"><span>text</span></input>
</body>
</html>
如您所见,文本没有居中,我该怎么办?
最佳答案
在这里。
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<head>
<style>
.w3-check,
.w3-radio {
vertical-align: top;
top: unset;
}
.w3-check span,
.w3-radio span {
vertical-align: middle;
}
</style>
</head>
<body>
<input class="w3-check" type="checkbox"><span>text</span></input>
</body>
</html>
关于html - 问题在复选框中间居中文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57665443/