我想在标题中创建一个带有一些文本背景颜色的HTML页面。我想要完全像这样,但我没有为这个特定的类w3-container w3-teal
获取CSS。
任何人都可以告诉我们如何获得这些类的CSS。
这是我正在拍摄的链接。 https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_containers_div_header
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<body>
<div class="w3-container w3-teal">
<h1>Header</h1>
</div>
<div class="w3-container">
<p>The w3-container class can be used to display headers.</p>
</div>
</body>
</html>
答案 0 :(得分:2)
这是css:
.w3-teal{ background-color: #009688; color:#fff;}
以下是工作代码:
.w3-container, .w3-panel {
padding: 0.01em 16px;
}
.w3-teal, .w3-hover-teal:hover {
color: #fff!important;
background-color: #009688!important;
}
<div class="w3-container w3-teal">
<h1>Header</h1>
</div>
<div class="w3-container">
<p>The w3-container class can be used to display headers.</p>
</div>
模板2:
$('.ToggleDiv').click(function() {
$('.menu').slideToggle(500);
});
* {
padding: 0px;
margin: 0px;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.w3-container,
.w3-panel {
padding: 0.01em 16px;
}
.w3-teal,
.w3-hover-teal:hover {
color: #fff!important;
background-color: #009688!important;
}
.ToggleDiv {
position: absolute;
top: 33px;
right: 40px;
z-index: 999;
font-size: 28px;
}
.ToggleDiv a {
color: #fff
}
h1 {
margin: 20px 0;
}
.menu {
width: 100%;
position: absolute;
left: 0px;
right: 0px;
top: 83px;
background: #fff;
display: none;
color: #000;
border: 1px solid #000;
padding: 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="w3-container w3-teal">
<h1>Header</h1>
<div class="ToggleDiv"><a href="#"><i class="fa fa-caret-down"></i></a>
</div>
<div class="menu">
<p>Helo I am being shown !!!</p>
<p>Helo I am being shown !!!</p>
</div>
</div>