1.什么是盒子模型?盒子模型的属性有哪几个?它们的作用分别是什么?
所谓盒子模型就是把HTML页面中的元素看作是一个矩形的盒子,也就是一个盛装内容的容器。
每个矩形都由元素的内容(content)、内边距(padding)、边框(border)和外边距(margin)组成。
盒子模型边框(border)
属性:border-width(设置边框宽度)|border-style(设置边框样式)|border-color(设置边框颜色)
边框有四条边,单独设置某条边(top|right|bottom|left)
如: border-top-width|border-top-style|border-top-color
盒子模型的内边距(padding)
padding-top:上内边距
padding-right:右内边距
padding-bottom:下内边距
padding-left:左内边距
盒子模型的外边距(margin)
margin-top:上外边距
margin-right:右外边距
margin-bottom:下外边距
margin-left:左外边距
2.盒子模型有哪几种解析方式?它们有什么区别?
盒子有两种解析方式:
当我们在样式表输入box-sizing时,会显示border-box和content-box,第一种是边框盒子尺寸,第二种是内容尺寸
当我们给一个元素设置尺寸时,默认设置的是元素内容的尺寸,也就是content-box,这种在后期布局时会有很多不便
而当我们用border-box时,我们设置的尺寸实际等于:内容尺寸+两边的内边距+两边的边框宽度
3. 制作北大青鸟网站的中心开班信息模块。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>北大青鸟中心开班信息模块</title>
<style>
.box{
width: 250px;
margin: 0px auto;
background: linear-gradient(to bottom,#CAEFFE,#FFFFED,white,white);
background: -webkit-linear-gradient(to bottom,#CAEFFE,#FFFFED,white,white);
border-radius: 20px;
border: 1px solid gray;
box-sizing: border-box;
}
a{
color: gray;
text-decoration: none;
}
a:hover{
color: red;
text-decoration:none;
}
ul{
list-style: none;
}
li{
background: url("dotBg.gif")0px -2px no-repeat;
font-size: 15px;
font-family: "Times New Roman", "楷体";
margin-top: -6px;
padding: 8px 16px;
width: 200px;
margin-left: -35px;
}
h1{
font-size: 15px;
color: white;
}
</style>
</head>
<body>
<div class="box">
<h1 ><img src="bg.gif" class="h1">中心开班信息</h1>
<ul>
<li><a href="#">8月12日:学历+技能班</a> </li>
<li> <a href="#">8月16日:高考特招班</a></li>
<li> <a href="#">8月23日:Java精英班</a></li>
<li> <a href="#">8月31日:学士后强化班</a> </li>
<li><a href="#">9月5日:大学生就业班</a> </li>
<li> <a href="#">9月9日:企业定向委培班</a></li>
<li><a href="#">9月16日:网络营销强化班</a> </li>
</ul>
</div>
</body>
4.制作商品分类列表页面
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>商品分类列表页</title>
<link rel="stylesheet" type="text/css" href="css/new_file.css"/>
</head>
<body>
<div id="nav">
<ul>
<li><a href="#">酒水、饮料</a></li>
<li><a href="#">进口食品</a></li>
<li><a href="#">休闲零食</a></li>
<li><a href="#">地方特产</a></li>
<li><a href="#">保健、冲调</a></li>
<li><a href="#">粮油、生鲜</a></li>
<li><a href="#">美容洗护</a></li>
<li><a href="#">清洁洗涤</a></li>
<li><a href="#">母婴、纸品</a></li>
<li><a href="#">家居百货</a></li>
</ul>
</div>
</body>
</html>
css代码:
#nav {
border: 2px solid orange;
border-radius: 8px;
width: 200px;
padding: 3px;
height: 479px;
}
a {
color: black;
text-decoration: none;
font-weight: bold;
}
a:hover{
color: orangered;
}
li {
list-style-type: none;
font-size: 14px;
font-family: "微软雅黑";
margin-left: -40px;
padding: 0px;
}
ul li:nth-of-type(1) {
margin-top: -18px;
background-image: url(../img/icon_01.jpg);
background-repeat: no-repeat;
line-height: 48px;
text-indent: 3.5em;
border-bottom: 1px dashed;
}
ul li:nth-of-type(2) {
background-image: url(../img/icon_02.jpg);
background-repeat: no-repeat;
line-height: 50px;
text-indent: 3.5em;
border-bottom: 1px dashed;
}
ul li:nth-of-type(3) {
background-image: url(../img/icon_03.jpg);
background-repeat: no-repeat;
line-height: 48px;
text-indent: 3.5em;
border-bottom: 1px dashed;
}
ul li:nth-of-type(4) {
background-image: url(../img/icon_04.jpg);
background-repeat: no-repeat;
line-height: 45px;
text-indent: 3.5em;
border-bottom: 1px dashed;
}
ul li:nth-of-type(5) {
background-image: url(../img/icon_05.jpg);
background-repeat: no-repeat;
line-height: 48px;
text-indent: 3.5em;
border-bottom: 1px dashed;
}
ul li:nth-of-type(6) {
background: url(../img/icon_06.jpg);
background-repeat: no-repeat;
line-height: 47px;
text-indent: 3.5em;
border-bottom: 1px dashed;
}
ul li:nth-of-type(7) {
background-image: url(../img/icon_07.jpg);
background-repeat: no-repeat;
line-height: 47px;
text-indent: 3.5em;
border-bottom: 1px dashed;
}
ul li:nth-of-type(8) {
background-image: url(../img/icon_08.jpg);
background-repeat: no-repeat;
line-height: 48px;
text-indent: 3.5em;
border-bottom: 1px dashed;
}
ul li:nth-of-type(9) {
background-image: url(../img/icon_09.jpg);
background-repeat: no-repeat;
line-height: 48.3px;
text-indent: 3.5em;
border-bottom: 1px dashed;
}
ul li:nth-of-type(10) {
background-image: url(../img/icon_10.jpg);
background-repeat: no-repeat;
line-height: 46px;
text-indent: 3.5em;
}
5.制作权威课程免费体验登录页面
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>免费体验登入页面</title>
<style>
div{
background-image: url(bg.jpg) ;
background-repeat: no-repeat;
height: 500px;
border-radius: 2px solid;
color: white;
width: 350px;
box-sizing: border-box;
margin-top: 0px;
text-align: center;
padding: 60px 50px 100px 0px;
font-size: 16px;
}
ul li{
list-style: none;
margin: 0px auto;
height: 30px;
}
span{
color: red;
}
ul li:nth-of-type(4){
padding-right: 150px;
}
ul li:nth-of-type(5){
padding-right: 120px;
}
</style>
</head>
<body>
<div>
<ul>
<form action="#">
<li><span>*</span>姓名:<input type="text" /></li>
<li><span>*</span>邮箱:<input type="text" /></li>
<li><span>*</span>电话:<input type="text" /></li>
<li>性别:<select name="sex>
<option value="">[请选择]</option>
<option value="1">男</option>
<option value="2">女</option>
</select>
</li>
<li>年龄:<select name="age">
<option value="">[请选择]</option>
<option value="1">16以下</option>
<option value="2">16~18</option>
<option value="3">18以上</option>
</select>
</li>
<p><img src="btn.jpg"/></p>
</form>
</ul>
</div>
</body>
</html>