Html 在背景图像上居中显示文本
我有一个背景图片。它包含一个用于显示总价的其他参数Html 在背景图像上居中显示文本,html,css,centering,Html,Css,Centering,我有一个背景图片。它包含一个用于显示总价的其他参数 当设备屏幕小的时候,显示的数字0集中在背景图像的中间和底部: 当我调整屏幕大小(更大)时,数字不再像第一个屏幕截图上那样固定: 将屏幕大小调整到第一张图片上的更大宽度后,如何显示0?我建议为0-div设置一个静态宽度: .total{ position:absolute; background-color:aqua; font-weight: bold; font-size:10px; text-align:center
当设备屏幕小的时候,显示的数字0集中在背景图像的中间和底部:
当我调整屏幕大小(更大)时,数字不再像第一个屏幕截图上那样固定:将屏幕大小调整到第一张图片上的更大宽度后,如何显示0?我建议为0-div设置一个静态宽度:
.total{
position:absolute;
background-color:aqua;
font-weight: bold;
font-size:10px;
text-align:center;
width: 40px; <----
left: 5%;
bottom:14px;
}
.total{
位置:绝对位置;
背景色:浅绿色;
字体大小:粗体;
字体大小:10px;
文本对齐:居中;
宽度:40px;我建议给0-div一个静态宽度:
.total{
position:absolute;
background-color:aqua;
font-weight: bold;
font-size:10px;
text-align:center;
width: 40px; <----
left: 5%;
bottom:14px;
}
.total{
位置:绝对位置;
背景色:浅绿色;
字体大小:粗体;
字体大小:10px;
文本对齐:居中;
宽度:40px;添加此
.divThree:after {
content: "";
display: inline-block;
vertical-align: middle;
height: 100%;
}
还有零钱,总共
.total{
background-color:aqua;
font-weight: bold;
font-size:10px;
text-align:center;
width: 90%;
vertical-align: middle;
display: inline-block;
}
添加此
.divThree:after {
content: "";
display: inline-block;
vertical-align: middle;
height: 100%;
}
还有零钱,总共
.total{
background-color:aqua;
font-weight: bold;
font-size:10px;
text-align:center;
width: 90%;
vertical-align: middle;
display: inline-block;
}
左值同上…约5px应约为右…否则将移动。左值同上…约5px应约为右…否则将移动。