【发布时间】:2018-06-23 23:42:03
【问题描述】:
我从 Udacity 的网站 - http://assignments.udacity-extras.appspot.com/courses/html-css/samples/style-1.html 发现了这个网络应用页面。在 CSS 部分中,提供了以下代码 -
body {
margin: 0;
}
#content {
max-width: 948px;
margin: 0 auto;
}
h1 {
background-color: #f8981C;
color: white;
font-size: 48px;
font-family: Helvetica;
text-align: center;
padding: 20px;
margin: 0;
}
.row {
display: flex;
flex-direction: row-reverse;
height: 100%
}
p {
color: grey;
font-size: 24px;
font-family: Helvetica;
}
.image > img {
border: 6px black dotted;
margin-left: 20px;
}
对于以下 HTML 页面 -
<!doctype html>
<html>
<head>
<title>Favorite App</title>
<link rel="stylesheet" type="text/css" href="style-1.css">
</head>
<body>
<div id="content">
<div>
<h1 id="banner">My Favorite App</h1>
</div>
<div class="row">
<div class="image"><img src="app.png">
</div>
<div class="description">
<p>
Some description here.
</p>
</div>
</div>
</div>
</body>
</html>
现在,所有内容都在带有 id content 的标签下,而 CSS 中的样式,#content 已被使用?为什么这样 ?它与 .row 有何不同?如果我们使用 .content 而不是 #content 会发生什么?
【问题讨论】: