我不知道如何居中图像。当我将“ center center”用作背景位置时,该女孩的头部没有显示。啊
body {
background: url(http://media.silabg.com/uf/common/catch-the-sun01.jpg) no-repeat center center;
}
http://jsfiddle.net/TomasRR/xvjdow6j/
有任何想法吗 ?
最佳答案
定义一些高度,以便图像知道应该如何居中/在何处居中:
html {
height: 500px;
}
body {
background: url("http://media.silabg.com/uf/common/catch-the-sun01.jpg") no-repeat center;
height: 100%;
width: 100%;
}
http://jsfiddle.net/az6x908x/
关于css - 垂直居中对齐背景图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25341611/