我不知道如何使图像居中。当我使用“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%;
}
关于css - 垂直居中背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25341611/