背景图像标题媒体查询



我想更改我的小型web项目标题中的背景图像,并相应地进行调整。我试着把一个类=";header_acceil";在我的标题中区分网站的不同部分,但它不起作用。我也看了其他论坛,但仍然没有找到任何可以帮助我的东西。

这是我的css代码和html代码:

@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
.header_accueil { 
background: url('images/4585760.jpg') no-repeat center center fixed; 
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
display:block;
}
}
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Site</title>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<header class="header_accueil">
</header>
</body>
</html>

这是我的文件夹,我所有的文件都存储在这里:

在此处输入图像描述

提前感谢您的帮助。

我更改了我的html代码和css代码:

@media only screen and (min-width : 320px) and (max-width : 480px) {
.header_accueil {

background: url('images/4585760.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
display:block;
height: 1000px;

}
}
@media only screen and (min-width : 1224px){
body{
display: none;
}
}
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Site</title>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<header class="header_accueil">
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
</header>
</body>
</html>

但一切都没有改变。

最新更新