gpt4 book ai didi

html - 我的媒体查询不起作用。包括元标记;链接 rel 链接

转载 作者:太空宇宙 更新时间:2023-11-03 23:02:09 30 4
gpt4 key购买 nike

这里是编码初学者。我正在尝试为我的移动设备网站设置断点,以便我的网站适合小屏幕。我只是想检查如果我缩小视口(viewport)的宽度,背景颜色是否会改变,但没有发生任何变化。也许我只是对一个简单的错误视而不见?

body {
margin: 0;
background-color: #4f4d4d;
overflow-x:hidden;
width: 100%;
height: auto;
}

ul {
margin-top: -80px;
list-style-type: none;
}

li {
font-size: 25px;
float: right;
font-weight: bold;
}

li a {
display: block;
text-decoration: none;
text-align: center;
font-family: sans-serif;
color: white;
border-left: 1px solid white;
padding: 23px;
}

li a:visited {
text-decoration: none;
color: white;
font-family: sans-serif;
}

li a:hover:not(.active) {
background-color: #333;
}


#header {
position: relative;
width: 100%;
height: 875px;
background-image: url(../images/bg.jpg);
background-repeat: no-repeat;
background-size: 100% 100%;
}

#nav {
width: 100%;
height: 75px;
background-color: black;
}

#logo {
width: 75px;
height: 75px;
}

#logo_text {
position: absolute;
display: inline;
top: -10px;
left: 80px;
font-size: 30px;
font-family: sans-serif;
color: white;
font-weight: bold;
}

#welcome_text_div {
position: absolute;
width: 1000px;
height: 300px;
top: 25%;
left: 0;
right: 0;
margin: auto;
}

#welcome_text {
color: white;
font-family: sans-serif;
text-transform: uppercase;
font-weight: bold;
font-size: 90px;
text-align: center;
}

#welcome_under_text {
color: white;
font-family: sans-serif;
text-align: center;
font-weight: bold;
margin-top: -80px;
font-size: 25px;
}

#alumni_div {
position: relative;
height: 800px;
width: 95%;
margin-right: auto;
margin-left: auto;
top: 100px;
margin-bottom: 50px;
}


.alumni_link:link {
text-decoration: none;
}

.alumni_link:visited {
color: white;
}

.alumni_link:hover {
color: grey;
}

#alumni_1 {
position: absolute;
width: 25%;
height: 100%;
background-color: black;
right: 77%;
}

#alumni_2 {
position: absolute;
width: 25%;
height: 100%;
background-color: blue;
right: 51%;
}

#alumni_3 {
position: absolute;
width: 25%;
height: 100%;
background-color: red;
left: 50.5%;
}

#alumni_4 {
position: absolute;
width: 25%;
height: 100%;
background-color: orange;
left: 77%;
}

.alumni_text {
font-family: sans-serif;
font-weight: bold;
font-size: 35px;
margin-top: 300px;
color: white;
text-align: center;
}

.graduate_text {
font-family: sans-serif;
font-weight: bold;
font-size: 20px;
color: white;
text-align: center;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CLC Website</title>
<link rel="stylesheet" href="main1.css">
<link rel="stylesheet" media="mediatype and|not|only (media feature)" href="mystylesheet2.css">
</head>
<body>
<div id="header">
<div id="nav">
<img src="../images/logo.png" id="logo" alt="logo">
<p id="logo_text">CLC</p>
<ul>
<li><a href="#">Contact Us</a></li>
<li><a href="#">Professors</a></li>
<li><a href="#">Courses</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Home</a></li>
</ul>
</div><!--/nav-->

<div id="welcome_text_div">
<p id="welcome_text">The Best Offer</p>
<p id="welcome_under_text">Truth evades a single definition and true understanding requires a comparative perspective</p>
</div><!--/welcome_text_div-->
</div><!--/header-->

<div id="alumni_div">
<div id="alumni_1">
<a href="#" class="alumni_link"><p class="alumni_text">Alumni Name <br> Class of 15</p><p class="graduate_text">Graduate School</p></a>
</div>

<div id="alumni_2">
<a href="#" class="alumni_link"><p class="alumni_text">Alumni Name <br> Class of 14</p><p class="graduate_text">Company A</p></a>
</div>

<div id="alumni_3">
<a href="#" class="alumni_link"><p class="alumni_text">Alumni Name <br> Class of 13</p><p class="graduate_text">Company B</p></a>
</div>

<div id="alumni_4">
<a href="#" class="alumni_link"><p class="alumni_text">Alumni Name <br> Class of 12</p><p class="graduate_text">Company C</p></a>
</div>
</div><!--/alumni_div-->
</body>
</html>

@media only screen and (max-width: 1024px) {
body {
margin: 0;
background-color: white;
overflow-x:hidden;
width: 100%;
height: auto;
}
}


@media only screen and (max-width: 767px) {
body {
margin: 0;
background-color: red;
overflow-x:hidden;
width: 100%;
height: auto;
}
}

@media only screen and (max-width: 480px) {
body {
margin: 0;
background-color: blue;
overflow-x:hidden;
width: 100%;
height: auto;
}
}

最佳答案

See this fiddle

括号不见了,更像这样:

@media only screen and (max-width: 1024px) {
body {
margin: 0;
background-color: white;
overflow-x:hidden;
width: 100%;
height: auto;
}
}


@media only screen and (max-width: 767px) {
body {
margin: 0;
background-color: red;
overflow-x:hidden;
width: 100%;
height: auto;
}
}

@media only screen and (max-width: 480px) {
body {
margin: 0;
background-color: blue;
overflow-x:hidden;
width: 100%;
height: auto;
}
}

关于html - 我的媒体查询不起作用。包括元标记;链接 rel 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36086707/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com