Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在背景图像上居中显示文本_Html_Css_Centering - Fatal编程技术网

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应约为右…否则将移动。