一种如何在图像中居中文本的方法 div
A way how to center text in an image div
我正在寻找一种方法可以让文字在图片中居中 div
我想在不影响其他文本的情况下将名字(罗纳尔多)放在中间。有没有人可以帮助我?
现场演示:"https://jsfiddle.net/ntasa5bc/1/"
谢谢!
朱兰
因为"Ronaldo"在一个绝对定位的<h2>
标签中,你需要给它一个宽度,并将text-align设置为居中。
#name {
position: absolute;
top: 172px;
width: 238px; // the same width as the gold badge image
text-align:center;
}
我正在寻找一种方法可以让文字在图片中居中 div
我想在不影响其他文本的情况下将名字(罗纳尔多)放在中间。有没有人可以帮助我?
现场演示:"https://jsfiddle.net/ntasa5bc/1/"
谢谢!
朱兰
因为"Ronaldo"在一个绝对定位的<h2>
标签中,你需要给它一个宽度,并将text-align设置为居中。
#name {
position: absolute;
top: 172px;
width: 238px; // the same width as the gold badge image
text-align:center;
}