目标图片
目前没有学习flex与grid布局,只能使用block,inline-block,position,float实现
<style>
*{
box-sizing: border-box;
}
img {
display: block;
}
.wd1200 {
width: 1200px;
margin: 0 auto
}
header, nav, .banner {
font-size: 0;
}
header > div, nav > .nav-sub, .banner > div, .tools > .tool {
display: inline-block;
vertical-align: middle;
}
header .logo, header .search, header .tools, header .tools .tool {
height: 76px;
line-height: 76px;
}
header .logo {
width: 20%;
cursor: pointer;
}
header .search {
line-height: 96px;
width: 55%;
text-align: right;
position: relative;
}
header .search input {
font-size: 15px;
width: 300px;
border-radius: 10px;
border: 1px solid #ccc;
line-height: 2;
}
header .search input:hover, .banner img:hover {
box-shadow: 0 0 10px #aaa;
}
header .search i {
position: absolute;
top: -5px;
right: 5px;
font-size: 25px;
}
header .tools {
width: 25%;
text-align: right;
}
header .tools .tool {
margin: auto 10px;
}
header .tools .tool i {
font-size: 28px;
line-height: 86px;
color: #333;
cursor: pointer;
}
header .tools .tool i:hover {
color: red;
}
nav > .nav-sub {
padding: 20px 0;
width: 25%;
}
nav > .nav-sub > .left, nav > .nav-sub > .left > div, nav > .nav-sub > .right, nav > .nav-sub > .right > .nav-to {
display: inline-block;
}
nav > .nav-sub > .left {
border-right: 1px solid #eee;
width: 25%;
}
nav > .nav-sub > .left > div{
width: 50%;
}
nav > .nav-sub > .left > div > i {
font-size: 40px;
line-height: 30px;
color: red;
}
nav > .nav-sub > .left > div > p{
padding: 5px 0;
text-align: center;
}
nav > .nav-sub > .left p, nav > .nav-sub > .right > .nav-to {
font-size: 14px;
}
nav > .nav-sub > .right > .nav-to {
width: 25%;
cursor: pointer;
padding: 5px 0;
text-align: center;
}
.banner .left-banner {
margin-right: 7px
}
</style>
<div class="wd1200">
<header>
<div class="logo"><img src="static/images/logo.png" alt=""></div>
<div class="search"><input type="search"/><i class="iconfont icon-sousuo2"></i></div>
<div class="tools">
<div class="tool"><i class="iconfont icon-huiyuan1"></i></div>
<div class="tool"><i class="iconfont icon-danmu1"></i></div>
<div class="tool"><i class="iconfont icon-fabu"></i></div>
<div class="tool"><i class="iconfont icon-fangda"></i></div>
<div class="tool"><i class="iconfont icon-huiyuan2"></i></div>
<div class="tool"><i class="iconfont icon-dianzan"></i></div>
</div>
</header>
<nav>
<div class="nav-sub">
<div class="left">
<div>
<i class="iconfont icon-html"></i>
</div>
<div>
<p>摄影</p>
<p>摄影</p>
</div>
</div>
<div class="right">
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
</div>
</div>
<div class="nav-sub">
<div class="left">
<div>
<i class="iconfont icon-html"></i>
</div>
<div>
<p>摄影</p>
<p>摄影</p>
</div>
</div>
<div class="right">
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
</div>
</div>
<div class="nav-sub">
<div class="left">
<div>
<i class="iconfont icon-html"></i>
</div>
<div>
<p>摄影</p>
<p>摄影</p>
</div>
</div>
<div class="right">
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
</div>
</div>
<div class="nav-sub">
<div class="left">
<div>
<i class="iconfont icon-html"></i>
</div>
<div>
<p>摄影</p>
<p>摄影</p>
</div>
</div>
<div class="right">
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
<div class="nav-to">摄影</div>
</div>
</div>
</nav>
<div class="banner">
<div class="left-banner">
<img src="static/images/2.jpg" alt="">
</div>
<div class="right-banner">
<img src="static/images/banner-right.jpg" alt="">
</div>
</div>
</div>
最终效果图
个人体会
在没有flex和grid的情况下,用简单的block,inline-block,position,float可以实现单端的精准布局,但是同样的效果,flex或者grid可以使用很少的代码实现,所以现在前端只会这种过时的CSS布局已经不能满足工作需求了。现在还没有学习CSS布局动画,展示方式更炫,CSS3还是很强大的。
虽然现在大部分后台框架基本是响应式布局,但是在前台首页的定制展示中,又很大的考验美工设计布局。同样对前端工程师也是很大的考验。
无论前端还是后端,技术更迭很快,如果不持续学习新技术,终将被这个行业抛弃。