仿PHP中文网页面布局
html代码:
<!DOCTYPE html>
<html lang="zh-CN">
<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" />
<link rel="stylesheet" href="static/css/reset.css" />
<link rel="stylesheet" href="//at.alicdn.com/t/font_3269118_mgnsjoz5gtp.css" />
<link rel="stylesheet" href="//at.alicdn.com/t/font_3280624_aealr8wo2wk.css" />
<link rel="stylesheet" href="static/css/header.css" />
<link rel="stylesheet" href="static/css/main-nav.css" />
<title>仿php.cn中文网首页差头部</title>
</head>
<body>
<!-- 页眉 -->
<header>
<!-- 1 顶部 -->
<div class="top">
<div class="content">
<div class="title">php中文网,程序员梦开始的地方!</div>
<div class="right">
<a href="" class="iconfont icon-tixing"></a>
<a href=""><img src="static/images/user-pic.jpeg" alt="" /></a>
</div>
</div>
</div>
<!-- 2 导航 -->
<div class="navs">
<div class="content">
<a href="" class="logo"><img src="static/images/logo.png" alt="" /></a>
<nav>
<a href="" class="active">首页</a>
<a href="">视频教程</a>
<a href="">学习路径</a>
<a href="">php培训</a>
<a href="">资源下载</a>
</nav>
<div class="search">
<input type="search" placeholder="输入关键字搜索" />
<span class="iconfont icon-fangdajing fdj"></span>
</div>
</div>
</div>
</header>
<!-- 主体 -->
<main>
<div class="navs">
<!-- 2行3列 -->
<div class="left">
<a href="">php开发</a>
<a href="">大前端</a>
<a href="">后端开发</a>
<a href="">数据库</a>
<a href="">移动端</a>
<a href="">运维开发</a>
<a href="">UI设计</a>
<a href="">计算机基础</a>
</div>
<div class="slider">
<a href="">
<img src="static/images/slider.jpeg" alt="" />
</a>
</div>
<div class="right">
<div class="phpTbxxTitle2">
<div class="phpTbxxCont2">
<img src="/static/images/user_avatar.jpg" alt="头像" />
<dl>
<dt>
<a href="">土老帽</a>
</dt>
<dd>P豆:14.00</dd>
</dl>
</div>
<div class="phpTbxxXue">
<a href="#" target="_blank" title="我的学习">我的学习</a>
</div>
</div>
<div class="phpWenda">
<p class="cont1">
<span>问答社区</span>
<a href="">答疑</a>
</p>
<p class="cont2">
<span>头条</span>
<a href="">头条内容</a>
</p>
<p class="cont3">
<span>新课</span>
<a href="">3.9号公益直播课</a>
</p>
<p class="cont4">
<span>新班</span>
<a href="">19期PHP直播课</a>
</p>
<p class="cont5">
<span>招募</span>
<a href="">课程合作计划</a>
</p>
<p class="cont6">
<span>公告</span>
<a href="">APP上线啦</a>
</p>
</div>
</div>
<div class="bottom-left">
<!-- 学习路径 -->
<div class="desc">
<div class="title">学习路径</div>
<span>全部7个></span>
</div>
<ul class="detail">
<li onclick="">
<img src="static/images//dgjj.png" alt="" />
<a href="">独孤九贱</a>
<span>9门课程</span>
</li>
<li onclick="">
<img src="static/images//ynxj.png" alt="" />
<a href="">玉女心经</a>
<span>9门课程</span>
</li>
<li onclick="">
<img src="static/images//tlbb.png" alt="" />
<a href="">天龙八部</a>
<span>9门课程</span>
</li>
<li onclick="">
<img src="static/images//phpkjkf.png" alt="" />
<a href="">自学指南</a>
<span>9门课程</span>
</li>
<li onclick="">
<img src="static/images//phpksrm.png" alt="" />
<a href="">趣味闯关</a>
<span>9门课程</span>
</li>
</ul>
</div>
<div class="bottom-right">
<ul class="phpXxljMenu">
<li onclick="">
<a class="iconfont icon-logo-wechat wx" href=""></a>
<a href="">官方公众号</a>
</li>
</ul>
<ul class="aBlack">
<li onclick="">
<a class="iconfont icon-QQ-circle-fill qq" href=""></a>
<a href="">官方QQ群</a>
</li>
</ul>
</div>
</div>
</main>
</body>
</html>
css代码
reset.css
/* 页面元素样式初始化 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
a {
text-decoration: none;
color: #555;
}
body {
background-color: rgb(243, 245, 247);
}
li {
list-style: none;
}
header .top {
width: 100vw;
height: 40px;
background-color: rgb(52, 52, 52);
color: #aaa;
}
header .top .content img {
width: 50%;
border-radius: 50%;
}
header .top .content {
width: 1200px;
display: grid;
grid-template-columns: 400px 100px;
grid-auto-rows: 40px;
place-content: space-between;
place-items: center start;
margin: auto;
}
header .top .content .right .iconfont {
color: #eee;
font-size: larger;
}
header .top .content .right {
display: grid;
grid-template-columns: repeat(2, 1fr);
place-items: center;
}
/* 导航 */
header .navs {
width: 100vw;
height: 90px;
background-color: #fff;
}
header .navs .content {
width: 1200px;
/* border: 1px solid #000; */
display: grid;
grid-template-columns: 140px 1fr 200px;
grid-auto-rows: 90px;
gap: 10px;
margin: auto;
place-items: center start;
}
header .navs .content img {
width: 100%;
}
header .navs .content nav a.active,
header .navs .content nav a:hover {
color: red;
font-weight: bold;
}
header .navs .content .search {
display: flex;
}
header .navs .content nav a {
padding: 0 10px;
}
header .navs .content .search input[type="search"] {
width: 200px;
height: 36px;
border: none;
outline: none;
background-color: #f7f8fa;
border-radius: 20px;
padding-left: 10px;
}
header .navs .content .search .fdj {
font-size: 22px;
color: #ccc;
position: relative;
left: -40px;
top: 5px;
}
`
main-nav.css
main {
font-size: 14px;
}
main .navs {
/* 2行3列 */
display: grid;
grid-template-columns: 160px 810px 190px;
grid-template-rows: 400px 80px;
gap: 20px;
place-content: center;
margin: 30px 0;
}
main .navs > * {
background-color: #fff;
border-radius: 20px;
/* outline: 1px solid red; */
}
/* 底部左侧占2列 */
main .navs .bottom-left {
grid-column: span 2;
}
main .navs .slider img {
width: 100%;
border-radius: 20px;
}
/* 左侧导航 */
main .navs .left {
display: grid;
place-items: center;
padding: 20px 0;
}
main .navs .left a:hover {
color: red;
background-color: rgb(250, 223, 227);
}
main .navs .left a {
border-radius: 20px;
padding: 10px 20px;
}
/* 底部左侧 */
main .navs .bottom-left {
display: grid;
grid-template-columns: 100px 1fr;
}
main .navs .bottom-left .desc {
display: grid;
place-items: center;
padding: 16px;
}
main .navs .bottom-left .detail img {
width: 100%;
grid-row: span 2;
}
main .navs .bottom-left .detail {
display: flex;
place-items: center;
place-content: space-between;
}
main .navs .bottom-left .detail li {
display: grid;
grid-template-columns: 36px 85px;
gap: 0 10px;
place-items: center start;
}
main .navs .bottom-left .detail li a {
font-size: 14px;
}
main .navs .bottom-left .detail li a:hover {
color: red;
}
main .navs .bottom-left .detail li span,
main .navs .bottom-left .desc span {
font-size: 12px;
color: #999;
}
main .navs .bottom-right .phpXxljMenu .iconfont,
main .navs .bottom-right .aBlack .iconfont {
font-size: 3em;
}
main .navs .bottom-right {
width: 190px;
}
main .navs .bottom-right li {
float: left;
width: 70px;
margin-top: 13px;
margin-left: 20px;
display: inline-block;
text-align: center;
}
main .navs .bottom-right li a {
display: inline-block;
text-align: center;
}
main .navs .right .phpTbxxTitle2 {
width: 190px;
height: 141px;
border-bottom: 1px solid #eeeeee;
}
main .navs .right .phpTbxxCont2 {
width: 155px;
margin: auto;
}
main .navs .right .phpTbxxTitle2 img {
float: left;
width: 40px;
height: 40px;
border-radius: 100px;
display: block;
margin-top: 20px;
}
main .navs .right .phpTbxxTitle2 dl {
float: right;
width: 105px;
margin-top: 15px;
}
main .navs .right .phpTbxxTitle2 dd {
height: 16px;
line-height: 16px;
overflow: hidden;
font-size: 12px;
color: #999999;
margin-top: 10px;
}
main .navs .right .phpTbxxTitle2 .phpTbxxXue {
display: block;
width: 150px;
height: 34px;
background: #f11717;
border-radius: 100px;
line-height: 34px;
text-align: center;
color: #ffffff;
text-decoration: none;
overflow: hidden;
margin-top: 20px;
margin-left: 20px;
}
main .navs .right .phpWenda {
width: 150px;
margin: auto;
padding-top: 7px;
}
main .navs .right .phpWenda p {
height: 18px;
line-height: 18px;
overflow: hidden;
}
main .navs .right .phpWenda .cont1 a {
display: inline-block;
width: 31px;
height: 16px;
background: #ff583d;
border-radius: 2px;
font-size: 15px;
color: #ffffff;
line-height: 16px;
text-align: center;
}