css之⽂字在图⽚上居中显⽰< html lang=“en”>
< head>
< meta charset=“UTF-8”>
< meta name=“viewport” content=“width=device-width, initial-scale=1.0”>
< title>Document< /title>
< style>
.children {
width: 100px;
height: 100px;
position: relative;
margin: auto;
text-align: center;
}
.words {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: red;
}
img {
width: 100%;
height: 100%;
}
< /style>
< /head>
< body>
css设置文字垂直居中< div class=“parent”>
< div class=“children”>
< span class=“words”>cdfced< /span>
< img src=“1.jpg” alt="">
< /div>
< /div>
< /body>
< /html>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论