Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:你怎么才写到这, 是不是一直没有写过作业?
代码:
html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>商品信息表</title>
<link rel="stylesheet" href="css/style1.css">
</head>
<body>
<table>
<caption>商品信息表</caption>
<thead>
<tr>
<th>类别</th>
<th>产品编号</th>
<th>名称</th>
<th>型号</th>
<th>产地</th>
<th>数量(KG)</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="3">笔类<br>办公用品</td>
<td>gb001</td>
<td>中性笔</td>
<td>蓝色</td>
<td>苏州</td>
<td>100</td>
</tr>
<tr>
<td>gb002</td>
<td>中性笔</td>
<td>黑色</td>
<td>佛山</td>
<td>3580</td>
</tr>
<tr>
<td>qb003</td>
<td>自动铅笔</td>
<td>橙光全自动铅笔</td>
<td>广州</td>
<td>5000</td>
</tr>
<tr>
<td rowspan="2">其他文具类</td>
<td>xp001</td>
<td>橡皮擦</td>
<td>晨光中号</td>
<td>苏州</td>
<td>1300</td>
</tr>
<tr>
<td>xz001</td>
<td>修正液</td>
<td>真彩速干</td>
<td>南京</td>
<td>8400</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="5" align="center">合计:</td>
<td>18380</td>
</tr>
</tfoot>
</table>
</body>
</html>
css:
table{
border:1px solid black;
box-sizing: border-box;
border-collapse: collapse;
width: 700px;
height: 300px;
margin: 50px auto;
}
table caption{
font-size: 1.5rem;
margin-bottom: 20px;
}
thead{
background: linear-gradient(lightblue,pink);
}
th,td{
border: 1px solid gray;
text-align: center;
}
tbody tr:nth-of-type(odd){
background-color: lightcyan;
}
table tbody>tr:first-of-type>td:first-of-type{
background-color: white;
}
table tfoot{
background:linear-gradient(lightgreen,white);
}
代码:
html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>课程表</title>
<link rel="stylesheet" href="css/style110102.css"
</head>
<body>
<article class="table">
<h2 class="caption">课程表</h2>
<div class="thead">
<p>
<span>序号</span>
<span>星期一</span>
<span>星期二</span>
<span>星期三</span>
<span>星期四</span>
<span>星期五</span>
</p>
</div>
<div class="tbody">
<p>
<span>1</span>
<span>语文</span>
<span>数学</span>
<span>英语</span>
<span>英语</span>
<span>体育</span>
</p>
<p>
<span>2</span>
<span>语文</span>
<span>数学</span>
<span>英语</span>
<span>英语</span>
<span>体育</span>
</p>
<p>
<span>3</span>
<span>语文</span>
<span>数学</span>
<span>英语</span>
<span>英语</span>
<span>体育</span>
</p>
<p>
<span>4</span>
<span>语文</span>
<span>数学</span>
<span>英语</span>
<span>英语</span>
<span>体育</span>
</p>
<p>
<span>5</span>
<span>语文</span>
<span>数学</span>
<span>英语</span>
<span>英语</span>
<span>体育</span>
</p>
</div>
<div class="tfoot">
<p>
<span>备注:值日生</span>
<span>同学1</span>
<span>同学2</span>
<span>同学3</span>
<span>同学4</span>
<span>同学5</span>
</p>
</div>
</article>
</body>
</html>
css:
.table{
display: table;
box-sizing: border-box;
border-collapse: collapse;
border:1px solid #444;
width:800px;
margin:auto;
color:#444;
}
.caption{
display: table-caption;
text-align: center;
}
.thead{
display: table-header-group;/*以表头的形式显示*/
text-align: center;
font-weight: bold; /*表头加粗*/
font: size 1.2rem;
letter-spacing: 5px; /*字间距*/
background:linear-gradient(blue,white);
color:white;
text-shadow: 1px 1px 0 blck;/*水平方向偏移、垂直方向、虚化*/
}
.tbody{
display: table-row-group;/*以表格主体形式显示*/
}
.tbody>p>span:first-of-type{
text-align: center; /*将第一列居中*/
}
div p{
display: table-row; /*将所有的ul转换为行*/
}
div p span{
display: table-cell; /*将所有的li转为单元格*/
border:1px solid #444;
padding:10px;
text-align: center;
}
.tfoot{
display:table-footer-group;
background-color: gainsboro;
}
代码:
html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户登录框始终居中</title>
<link rel="stylesheet" href="css/style110104.css"
</head>
<body>
<div>
<h3>用户登录</h3>
<form action="" method="POST">
<p>
<label for="username">用户名</label>
<input type="text" id="username" name="username" value="">
</p>
<p>
<label for="password">登录密码</label>
<input type="password" id="password" required placeholder="8-12位含字母、数字">
</p>
<p>
<button>登录</button>
</p>
</form>
</div>
</body>
</html>
css:
div{
width: 230px;
height: 180px;
border: 1px solid gainsboro;
}
div{
position: absolute;
left: 50%;
right: 50%;
top: 50%
}
body{
border: 1px solid gainsboro;
position: relative;
height: 1000px;
background-color: honeydew;
}
div{
position: fixed;
}
模拟案例实现圣杯布局:
html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>圣杯布局</title>
<link rel="stylesheet" href="css/style110106.css"
</head>
<body>
<header>年终大促</header>
<main>
<article>活动区</article>
<aside>
<div>服装</div>
<div>化妆品</div>
<div>食品</div>
</aside>
<aside>
<div>会员登录</div>
<div>最新活动</div>
<div>下载APP</div>
</aside>
</main>
<footer>中文网</footer>
</body>
</html>
css:
body{
width:1000px;
}
header,footer{
height: 60px;
background-color: lavender;
text-align: center;
}
main{
padding-left: 200px;
padding-right: 200px; /*给左右边栏预留空间*/
box-sizing: border-box;
overflow: hidden;
}
main>article{
box-sizing: border-box;
background-image: url(flower.jpg);
width: 100%;
min-height: 600px;
}
main>aside{
box-sizing: border-box;
min-height: 600px;
width: 200px;
}
main>aside:first-of-type{
background-color: lightcyan;
margin-left:-100%;
position: relative;
left: -200px;
}
main>aside:last-of-type{
background-color: lightskyblue;
margin-left: -200px;
position: relative;
left:200px;
}
main>article,
main>aside:first-of-type,
main>aside:last-of-type{
float: left;
}
流程与布局思路:
先用HTML写出框架的主体内容:包含头部、主体、页脚信息;主体内容布局时,分为左侧导航栏、中间活动主体区及右侧内容区,为使显示屏幕向左右缩窄时,先从右边屏幕内容开始部分显示,布局时,将中间区域写在左、右侧边栏前;框架布局好后,用css布局来让框架内容按照圣杯布局的样式展现;写css时,按照头部、页脚、主体内容的顺序设置,其中主体部分的布局思路为,左右两侧边栏可以看成是两个盒子,为左右两侧设置padding值,挤出中间部分,为让盒子的大小自适应设置的框架大小,为盒子设置box-sizing,再分别设置中间、左右侧的边框、颜色、宽高、位置,在设置左右侧边栏的位置时,用相对位置设置,最后设置主体区浮动,并让其在屏幕框架内,设置overflow属性,并在css设置开头设置body的宽度,这样保证布局在缩放的情况下正常显示。