任务目的
- 针对设计稿样式进行合理的HTML架构,包括以下但不限于:
- 掌握常用HTML标签的含义、用法
- 能够基于设计稿来合理规划HTML文档结构
- 理解语义化,合理地使用HTML标签来构建页面
- 掌握基本的CSS编码,包括以下但不限于:
- 了解CSS的定义、概念、发展简史
- 掌握CSS选择器的含义和用法
- 实践并掌握CSS的颜色、字体、背景、边框、盒模型、简单布局等样式的定义方式
任务要求:http://ife.baidu.com/task/detail?taskId=5
[demo] https://happyshj.github.io/mygit-test_ife-task_05/task_05.html
HTML代码为:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="task_05.css">
<title>task_01</title>
</head>
<body>
<header>
<nav>
<img src="meitu.jpg" alt="美图">
<ul>
<li><a href="#link4">导航链接四</a></li>
<li><a href="#link3">导航链接三</a></li>
<li><a href="#link2">导航链接二</a></li>
<li><a href="#link1">导航链接一</a></li>
</ul>
</nav>
</header>
<aside>
<h3>这里以后是一个侧栏,这是侧栏的标题</h3>
<form>
<label class="mail">请输入邮箱地址 <input type="text"placeholder="这是一个文本框"></label>
<p class="text">邮箱地址请按要求格式输入</p>
<label class="password">请输入密码 <input type="password" placeholder="这是一个文本框" ></label>
<br />
<label class="password1">请重复输入密码 <input type="password" placeholder="这是一个文本框"></label>
<p class="text">密码请为6-16位英文数字</p>
<div class="sex">
<span>性别 </span>
<label><input type="radio" name="sex" value="m" checked>男</label>
<label><input type="radio" name="sex" value="w">女</label>
</div>
<div class="city">
<label>城市
<select name="city">
<option value="beijing" selected>北京</option>
<option value="guangzhou">广州</option>
</select>
</label>
</div>
<div class="love">
<span>爱好 </span>
<label><input type="checkbox">运动</label>
<label><input type="checkbox">艺术</label>
<label><input type="checkbox">科学</label>
</div>
<div class="textarea">
<div class="label">
<label>个人描述</label>
</div>
<textarea placeholder="这是一个多行输入框,输入您的个人描述"></textarea>
</div>
<button type="submit">确认提交</button>
</form>
</aside>
<div class="container">
<article class="article1">
<h2><a id="link1">文章一级标题</a></h2>
<h3>文章二级标题</h3>
<p>
<span>文章作者</span>
<span>文章发表时间</span>
</p>
<p class="p1">这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落,<br />换行了<br />这是一个很长很长的段落,
这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落,这是一个很长很长的段落,换行了<br />
这是一个很长很长的段落,这是一个很长很长的段落,
<a href="http://ife.baidu.com">这里有一个链接链接到http://ife.baidu.com</a>
这是一个很长很长的段落,这是一个很长很长的段落,<b>这里有个粗体字</b>
这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落。</p>
<img src="meitu.jpg" alt="美图">
<p class="p1">这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落,这是一个很长很长的段落,换行了<br />
这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
<b>这里有个粗体字</b>这是一个很长很长的段落,这是一个很长很长的段落,
<a href="http://ife.baidu.com" target="_blank">这里有一个链接点击后打开新窗口链接到http://ife.baidu.com</a>
这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落,这是一个很长很长的段落。</p>
</article>
<article class="article2">
<h2><a id="link2">另一篇文章一级标题</a></h2>
<h3>文章二级标题</h3>
<p>
<span>文章作者</span>
<span>文章发表时间</span>
</p>
<p class="p1">这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落,<br />换行了<br />这是一个很长很长的段落,
这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落,这是一个很长很长的段落,换行了<br />
这是一个很长很长的段落,这是一个很长很长的段落,
<a href="http://ife.baidu.com">这里有一个链接链接到http://ife.baidu.com</a>
这是一个很长很长的段落,这是一个很长很长的段落,<b>这里有个粗体字</b>
这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落,这是一个很长很长的段落,这是一个很长很长的段落,
这是一个很长很长的段落。</p>
<img src="meitu.jpg" alt="美图">
<ul>
<li>列表项目一</li>
<li>列表项目二</li>
<li>列表项目三</li>
</ul>
</article>
<article class="article3">
<h2><a id="link3">图片</a></h2>
<figure>
<figcaption>美图</figcaption>
<img src="meitu.jpg" alt="美图">
</figure>
<figure>
<figcaption>美图</figcaption>
<img src="meitu.jpg" alt="美图">
</figure>
<figure>
<figcaption>美图</figcaption>
<img src="meitu.jpg" alt="美图">
</figure>
<figure>
<figcaption>美图</figcaption>
<img src="meitu.jpg" alt="美图">
</figure>
<figure>
<figcaption>美图</figcaption>
<img src="meitu.jpg" alt="美图">
</figure>
<figure>
<figcaption>美图</figcaption>
<img src="meitu.jpg" alt="美图">
</figure>
<figure>
<figcaption>美图</figcaption>
<img src="meitu.jpg" alt="美图">
</figure>
<figure>
<figcaption>美图</figcaption>
<img src="meitu.jpg" alt="美图">
</figure>
<figure>
<figcaption>美图</figcaption>
<img src="meitu.jpg" alt="美图">
</figure>
<figure>
<figcaption>美图</figcaption>
<img src="meitu.jpg" alt="美图">
</figure>
</article>
<article class="article4">
<h2><a id="link4">最后一篇文章一级标题</a></h2>
<h3>文章二级标题</h3>
<p>
<span>文章作者</span>
<span>文章发表时间</span>
</p>
<ol>
<li>排名1</li>
<li>排名2</li>
<li>排名3</li>
</ol>
<p>下面是一个表格,给表格加了一个border="1"好让你看出是一个表格</p>
<table>
<thead>
<tr>
<th>表头</th>
<th>表头</th>
<th>表头</th>
</tr>
</thead>
<tbody>
<tr>
<td>表内容单元格</td>
<td>表内容单元格</td>
<td><a href="#">操作</a></td>
</tr>
<tr>
<td>表内容单元格</td>
<td>表内容单元格</td>
<td><a href="#">操作</a></td>
</tr>
<tr>
<td>表内容单元格</td>
<td>表内容单元格</td>
<td><a href="#">操作</a></td>
</tr>
<tr>
<td>表内容单元格</td>
<td>表内容单元格</td>
<td><a href="#">操作</a></td>
</tr>
</tbody>
<tfoot>
<tr>
<td>总计</td>
<td colspan="2">1000</td>
</tr>
</tfoot>
</table>
</article>
</div>
<footer>
<span>版权所有©</span>
</footer>
</body>
</html>
CSS代码为:
*{
margin: 0;
padding: 0;
}
body{
background-color: gray;
font-family: SimSun-ExtB;
min-width: 740px;
}
nav{
background-color: darkslategray;
width: 100%;
height: 70px;
}
nav img{
height: 50px;
width: 50px;
float: left;
border-radius: 50px;
margin-left: 20px;
margin-top: 10px;
}
nav ul li{
line-height: 70px;
float: right;
width: 100px;
padding-right: 10px ;
}
nav ul li a{
color: white;
text-decoration: none;
}
.container{
margin-right: 480px;
}
.article1,.article2,.article3,.article4,aside{
margin: 20px;
background-color: white;
padding: 30px 20px;
}
h3{
color: grey;
margin-top: 10px;
margin-bottom: 10px;
}
p span{
color: grey;
font-size: 14px;
}
.p1{
font-size: 15px;
line-height: 25px;
text-indent: 2em;
margin-top: 10px;
margin-bottom: 10px;
}
.article1 img,.article2 img{
width: 120px;
height: 150px;
}
.article2 ul li{
list-style-type: none;
margin-top: 10px;
}
.article3 figure{
border: 1px solid lightgray;
width: 120px;
height: 150px;
margin-top: 20px;
margin-left: 40px;
display: inline-block;
}
.article3 figure figcaption{
text-align: center;
margin: 10px auto;
font-size: 14px;
}
.article3 figure img{
width: 100px;
height: 100px;
margin-left: 10px;
margin-right: 10px;
}
.article4 ol li{
margin-left: 50px;
margin-top: 10px;
margin-bottom: 10px;
}
.article4 table{
width: 94%;
margin-left: 5px;
margin-right: 5px;
border-collapse: collapse;
}
.article4 table td,.article4 table th{
border: 1px solid gray;
height: 25px;
font-size: 14px;
}
.article4 table th{
background-color: black;
color: white;
text-align: left;
}
.article4 table tfoot{
background-color: gray;
}
aside{
margin: 20px;
background-color: white;
width: 400px;
float: right;
}
aside h3{
color: black;
}
aside form{
font-size: 14px;
}
.mail{
margin-left: 20px;
}
.text{
color: gray;
font-size: 14px;
margin-left: 124px;
margin-top: 10px;
margin-bottom: 20px;
}
.password{
margin-left: 48px;
display: inline-block;
margin-bottom: 10px;
}
.password1{
margin-left: 20px;
margin-top: 10px;
}
.sex,.city,.love{
margin-left: 90px;
margin-bottom: 10px;
}
.textarea{
margin-left: 60px;
margin-bottom: 10px;
}
.textarea .label{
float: left;
margin-right: 8px;
}
.textarea textarea{
width: 250px;
height: 100px;
font-size: 18px;
}
button{
width: 360px;
height: 40px;
margin-left: 20px;
background-color: blue;
border: 1px solid blue;
border-radius: 10px;
color: white;
font-size: 18px;
font-weight: bold;
}
footer{
background-color: black;
width: 100%;
height: 50px;
color: white;
text-align: center;
line-height: 50px;
}
图片为: