我遇到的真正令人沮丧的问题是,我在网站的后台播放了全屏视频,但是,我正在设计移动版式,并且试图用图像替换视频。但是,它不会更改为移动设备着陆页上的图像-请参见下面的代码。
*/ CSS CODE */
@media(max-width:768px) {
.header {
width: 100%;
background-size: contain;
background-position: center;
}
.title h1 {
font-size: 40px;
color: #fff;
top: 150px;
}
p {
font-size: 20px;
font-weight: 600;
}
.middle {
height: 1400px;
background-color: #1f1f20;
}
.social {
margin: 0px;
padding: 10px;
position: absolute;
top: 380%;
left: 30%;
transform: translate(-50%, -50%);
align-items: center;
}
.bottom {
height: 50px;
background-color: #fff;
margin: auto;
font-size: 20px;
color: white;
text-align: justify;
text-align: center;
}
.Ishmayl-writeup {
font-size: 20px;
font-weight: 700;
line-height: 30px;
color: #1f1f20;
}
.title video {
display: none;
}
.title video {
background: url('/images/3.jpg');
background-size: cover;
}
}
@media(min-aspect-ratio:16/9) {
.header {
width: 100%;
height: auto;
}
.header video {
width: 100%;
height: auto;
}
@media(max-aspect-ratio:16/9) {
.header {
width: auto;
height: 100%;
}
.header video {
width: auto;
height: 100%;
}
}
}
*/ HTML CODE */
<body>
<section class="top" id="Home">
<header>
<div class="title">
<div class="video">
<video src="Video/Mountain.mp4" autoplay="true" loop="true" muted type="video/mp4"></video>
<div class="overlay"></div>
答案 0 :(得分:0)
我会为台式机和手机设置两个不同的类,如下所示:
<div class="title">
<div class="video onlydesktop">
<video src="Video/Mountain.mp4" autoplay="true" loop="true" muted type="video/mp4"></video>
<div class="overlay"></div>
</div>
<div class="photo onlymobile">
<div class="overlay"></div>
</div>
</div>
.photo {
background: url('https://images.unsplash.com/photo-1508138221679-760a23a2285b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80');
background-size: cover;
width: 100%;
height: 500px;
}
@media(min-width:769px) {
.onlydesktop{
display:inline;
}
.onlymobile{
display:none;
}
@media(max-width:768px) {
.onlydesktop{
display:none;
}
.onlymobile{
display:inline;
}
.header {
width: 100%;
background-size: contain;
background-position: center;
}
.title h1 {
font-size: 40px;
color: #fff;
top: 150px;
}
p {
font-size: 20px;
font-weight: 600;
}
.middle {
height: 1400px;
background-color: #1f1f20;
}
.social {
margin: 0px;
padding: 10px;
position: absolute;
top: 380%;
left: 30%;
transform: translate(-50%, -50%);
align-items: center;
}
.bottom {
height: 50px;
background-color: #fff;
margin: auto;
font-size: 20px;
color: white;
text-align: justify;
text-align: center;
}
.Ishmayl-writeup {
font-size: 20px;
font-weight: 700;
line-height: 30px;
color: #1f1f20;
}
.title video {
display: none;
}
}