我设法使背景图像在台式机上适合全屏显示,但在移动设备上它向底部留了一些空间。
找到CSS here。
* {
padding: 0;
margin: 0
}
body {
background-color: #000000;
}
.crossfade > figure {
animation-name: imageAnimation;
animation-duration: 20s;
animation-timing-function: linear;
animation-delay: 0s;
animation-iteration-count: infinite;
backface-visibility: hidden;
background-size: cover;
background-position: center center;
color: transparent;
height: 100%;
left: 0px;
opacity: 0;
position: static;
top: 0px;
width: 100%;
z-index: 0;
}
.crossfade > figure:nth-child(1) {
background-image: url('../Pictures/IMG_5956.JPG');
}
.crossfade > figure:nth-child(2) {
animation-delay: 10s;
background-image: url('../Pictures/IMG_3497.JPG');
}
.crossfade > figure:nth-child(3) {
animation-delay: 20s;
background-image: url('../Pictures/IMG_2548.JPG');
}
.crossfade > figure:nth-child(4) {
animation-delay: 30s;
background-image: url('../Pictures/IMG_1251.JPG');
}
.crossfade > figure:nth-child(5) {
animation-delay: 40s;
background-image: url('../Pictures/IMG_0429.JPG');
}
@keyframes imageAnimation {
0% {
animation-timing-function: ease-in;
opacity: 0;
}
8% {
animation-timing-function: ease-out;
opacity: 0.3;
}
17% {
opacity: 1
}
25% {
opacity: 1
}
100% {
opacity: 1
}
}
.header{
position: relative;
z-index: 1000;
padding-top: 70px;
padding-bottom: 50px;
padding-left: 50px;
padding-right: 50px;
}
.quote{
position: relative;
z-index: 1000;
padding-bottom: 50px;
padding-left: 50px;
padding-right: 50px;
}
.icons{
position:relative;
bottom: 0;
margin: auto;
padding-bottom: 20px;
width: 100%;
text-align: center;
}
答案 0 :(得分:2)
用于移动媒体。将高度设置为100%,背景位置固定。
.crossfade > figure {
background: url(image url) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height: 100%;
overflow: hidden;
}
答案 1 :(得分:0)
<style type="text/css">
html {
background: url(images/bd.jpg) no-repeat center center fixed;
background-size: cover;
}
</style>
此背景尺寸用于将背景图片设置为全屏浏览器(铬)。
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
将其用于其他浏览器,例如IE,Firefox,Opera
答案 2 :(得分:0)
[https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_full_page][1]
使用上面的链接
background-position: center;
background-repeat: no-repeat;
background-size: cover;