设计图
https://s3.bmp.ovh/imgs/2023/02/10/f04eca2ec8533891.jpg
页面构成和思路
- 页面由头部header+轮拨图banner+选项卡片section+案例case+客户client+关于我们&新闻aboutUs&news+底部footer组成
- 头部底部等等用到了h5新增标签
- 使用float浮动进行盒模型的水平布局,使用内外边距padding和margin进行上下左右间距的拉开
- 在margin:top塌陷的地方是通过改为设置padding:top再将height减去相应像素来实现的
- 网页在浏览器中的居中显示是通过设置html的宽度100%,body设置一个固定宽度然后margin:0 auto;来实现的
完整代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BEANCMS</title>
<link rel="stylesheet" href="./font/iconfont.css" />
<style>
* {
margin: 0;
padding: 0;
}
ul,
li {
list-style-type: none;
}
a{
text-decoration: none;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: normal;
}
html {
width: 100%;
}
body {
width: 1146px;
margin: 0 auto;
/* overflow: hidden; */
}
/* 1.header头部 */
header {
width: 100%;
height: 60px;
background: #e83928;
margin: 0 auto;
}
header > span {
float: left;
margin-left: 70px;
font-size: 20px;
color: #fff;
font-family: SimHei;
font-weight: 900;
line-height: 60px;
}
header > ul {
float: left;
margin-left: 156px;
}
header li {
float: left;
line-height: 60px;
font-size: 14px;
font-weight: 600;
margin-right: 44px;
}
header a{
color:#fff;
}
header a:active{
text-decoration: underline;
}
.lianxi {
float: right;
margin-right: 65px;
}
#weibo,
#qq,
#phone,
.tel {
float: left;
color: #fff;
line-height: 60px;
margin-right: 10px;
font-weight: 600;
}
/* 2.banner */
.banner {
width: 100%;
height: 522px;
}
/* 3.section */
section {
height: 226px;
}
.container {
width: 16.5%;
height: 186px;
border-right: 1px dashed #565656;
color: #666666;
text-align: center;
margin-top: 16px;
margin-bottom: 32px;
float: left;
}
.container:last-child {
border: none;
}
.container > .iconfont {
font-size: 50px;
}
.container h3 {
font-size: 16px;
line-height: 34px;
color: #7c7c7c;
}
.container h5 {
font-size: 14px;
line-height: 24px;
}
/* 4.case */
#case {
width: 100%;
height: 490px;
float: none;
background: #eeeeee;
}
.title {
/* 减去padding值 */
width: calc(100% - 80px);
/* height: 102px; */
height: 34px;
/* 避开margin-top塌陷 */
padding: 42px 8px 26px 72px;
}
.eng {
font-size: 34px;
font-weight: 900;
}
.cn {
font-size: 20px;
}
.box1,
.box2,
.box3 {
width: 320px;
height: 320px;
background: #fff;
float: left;
margin-left: 20px;
}
.box1 {
margin-left: 72px;
}
.caseBox .text {
margin: 6px 10px;
}
.caseBox h4 {
height: 34px;
line-height: 34px;
font-size: 14px;
border-bottom: 1px solid #e3e3e3;
}
.caseBox h6 {
margin-top: 6px;
font-size: 12px;
line-height: 20px;
color: #8384c0;
}
.caseBox p {
float: right;
font-size: 10px;
color: #959597;
}
/* 5.client */
#client {
width: 100%;
height: 254px;
}
.clientBox {
width: 194px;
height: 152px;
border: 1px solid #afafaf;
float: left;
margin-left: 8px;
position: relative;
}
.clientBox > img {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
}
.first {
margin-left: 72px;
}
/* 6.aboutUs和news */
article {
width: calc(100% - 190px);
/* width:100%; */
height: 392px;
padding-left: 72px;
padding-top: 52px;
/* border: 1px solid green; */
}
.aboutUs {
border-right: 1px dashed #565656;
padding-right: 40px;
/* background: pink; */
}
.news {
margin-left: 40px;
margin-right: -40px