我正在编写一个网站,但每个CSS文档只能有一个div。
这是我的代码:
body {
width: 100%;
height: 100%;
margin: 0px;
background-color: white;
background: url("https://static.pexels.com/photos/160133/pexels-photo-160133.jpeg");
background-size: cover;
}
#menu {
width: 100%;
height: 60px;
background-color: white;
float: right;
}
#menu ul {
list-style: none;
margin-right: 25%;
}
#menu li {
padding-top: 7px;
float: right;
color: black;
display: inline;
margin-right: 15px;
font-family: 'Josefin Sans', sans-serif;
}
#menu a {
text-decoration: none;
color: black;
}
#menu a:hover {
text-decoration: none;
color: #DD0604;
}
#menu li:hover::first-letter {
color: black;
}
#menu li::first-letter {
color: #DD0604;
}
#menu img {
width: 70px;
height: 70px;
margin-top: -25px;
}
/* This doesnt work */
.devices-and-text {
color: green;
}
<head>
<title>Tvorba webstránok FAXEOT</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Keywords" content="">
<meta name="">
<link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
<link rel="stylesheet" type="text/css" href="css/main.css">
<link href="https://fonts.googleapis.com/css?family=Josefin+Sans" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Poiret+One" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Josefin+Sans" rel="stylesheet">
</head>
<body>
<div id="menu">
<ul>
<li style="float: left; margin-left: 30%;"> <img src="images/logo.png"> </li>
<li class="blue"><a href="#"> Menu </a></li>
<li><a href="#"> Menu </a></li>
<li><a href="#"> Menu </a></li>
<li><a href="#"> Menu </a></li>
</ul>
</div>
<div class="devices-and-text">
This text doesn't work...
</div>
</body>
网站显示菜单,菜单的一切正常。但我的div“设备和文本”仍然是黑色而不是绿色。当我将样式放入index.php时,一切正常。