第1关 初识CSS:丰富多彩的网页样式
step1/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello World</title>
<style type="text/css">
body {
text-align: center;
}
h1 {
text-align: center;
font-size:40px;
color: #62A8CB;
}
img {
height: 250px;
}
p {
color:grey;
font-size:18px;
}
</style>
</head>
<body>
<h1>CSS让网页样式更丰富</h1>
<img src="https://www.educoder.net/attachments/download/189467">
<p>使用CSS(Cascading Style Sheets),可以使网页样式更加的丰富多彩,它解决内容与表现分离的问题,提高了工作效率。</p>
</body>
</html>
step1/example.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello World</title>
<style type="text/css">
body {
background-color: teal;
}
h1 {
color:white;
font-size: 36px;
text-align: center;
}
</style>
</head>
<body>
<h1>CSS让网页样式更丰富</h1>
</body>
</html>
第2关:CSS样式引入方式
step2/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>O Captain! My Captain!</title>
<link rel="stylesheet" href="step2/CSS/style.css">
<style type="text/css">
h1 {
color:darkblue;
}
img {
float: left;
margin-right: 1em;
}
</style>
</head>
<body>
<div>
<h1 style="color:cornflowerblue">O Captain! My Captain!</h1>
<img src="https://www.educoder.net/attachments/download/170157" width="300" height="175" alt="Blue Flax (Linum lewisii)" />
<p>O Captain! my Captain! our fearful trip is done,
The ship has weather’d every rack, the prize we sought is won,
The port is near, the bells I hear, the people all exulting,
While follow eyes the <em>steady keel</em>, the vessel grim and daring;</p>
<p ><small style="color:lightslategray;font-size:10px;">
© Walt Whitman</small></p>
</div>
</body>
</html>
step2/index.html
body {
font-family: 'Times New Roman', Times, serif;
}
div {
border: 1px solid #000;
overflow: hidden;
padding: 0 1em .25em;
}
h1 {
color: green;
}
p {
/* ********** BEGIN ********** */
font-weight: bold;
/* ********** END ********** */
}