伪元素文字居中问题

2019-09-29  本文已影响0人  videring

浏览器版本:

chrome 76.0.3809.87

代码:

<div info="暂无数据" class="has-no-data"></div>
.has-no-data {
    width: 400px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-items: center;
    position: relative;
}

效果1:

.has-no-data::after {
    content: attr(info);
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
image.png

效果2:

.has-no-data::after {
    content: attr(info);
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
}
image.png
上一篇 下一篇

猜你喜欢

热点阅读