Bootstrap基础案例
<!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"> <title>Document</title> <!--[if lt IE 9]> <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script> <![endif]--> <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="css/index.css"> <title>阿里佰秀</title> </head> <body> <div class="container"> <div class="row"> <header class='col-md-2'> <div class="logo"> <a href="#"> <img class='hidden-xs' src="images/logo.png" alt=""> <span class='visible-xs'>阿里佰秀</span> </a> </div> <div class="nav"> <ul> <li><a href="#" class='glyphicon glyphicon-camera'>生活馆</a></li> <li><a href="#" class='glyphicon glyphicon-picture'>自然汇</a></li> <li><a href="#" class='glyphicon glyphicon-phone'>科技潮</a></li> <li><a href="#" class='glyphicon glyphicon-gift'>奇趣事</a></li> <li><a href="#" class='glyphicon glyphicon-glass'>美食杰</a></li> </ul> </div> </header> <article class='col-md-7'> <div class="news clearfix"> <ul> <li> <a href="#"> <img src="upload/lg.png" alt=""> <p>阿里佰秀</p> </a> </li> <li> <a href="#"> <img src="upload/1.jpg" alt=""> <p>奇了,成都一小区护卫长得像马云,市民争相拍照留恋</p> </a> </li> <li> <a href="#"> <img src="upload/3.jpg" alt=""> <p>奇了,成都一小区护卫长得像马云,留恋</p> </a> </li> <li> <a href="#"> <img src="upload/4.jpg" alt=""> <p>奇了,成都一小区护卫长,市民争相拍照留恋</p> </a> </li> <li> <a href="#"> <img src="upload/2.jpg" alt=""> <p>阿奇了,成小区护卫长得争相拍照留恋</p> </a> </li> </ul> </div> <div class="publish"> <div class="row"> <div class="col-sm-9"> <h3>生活馆 关于指甲的10个健康知识 你知道几个?</h3> <p class="text-muted hidden-xs">阿里佰秀 发布于2020-10-12</p> <p class='hidden-xs'>指甲时人身体上的关键部件,没了他,人就会受苦啊!别小看它,他就像铠甲一样可以保护人的指头,快看看关于它的十个常识吧!</p> <p class="text-muted">阅读(2417) 评论(1) 赞(18) <span class='hidden-xs'>标签:健康 / 感染 / 指甲 / 疾病 / 皮肤 / 营养 / 趣味生活</span> </p> </div> <div class="col-sm-3 hidden-xs"> <img src="upload/3.jpg" alt=""> </div> </div> <div class="row"> <div class="col-sm-9"> <h3>生活馆 关于指甲的10个健康知识 你知道几个?</h3> <p class="text-muted hidden-xs">阿里佰秀 发布于2020-10-12</p> <p class='hidden-xs'>指甲时人身体上的关键部件,没了他,人就会受苦啊!别小看它,他就像铠甲一样可以保护人的指头,快看看关于它的十个常识吧!</p> <p class="text-muted">阅读(2417) 评论(1) 赞(18) <span class='hidden-xs'>标签:健康 / 感染 / 指甲 / 疾病 / 皮肤 / 营养 / 趣味生活</span> </p> </div> <div class="col-sm-3 hidden-xs"> <img src="upload/3.jpg" alt=""> </div> </div> <div class="row"> <div class="col-sm-9"> <h3>生活馆 关于指甲的10个健康知识 你知道几个?</h3> <p class="text-muted hidden-xs">阿里佰秀 发布于2020-10-12</p> <p class='hidden-xs'>指甲时人身体上的关键部件,没了他,人就会受苦啊!别小看它,他就像铠甲一样可以保护人的指头,快看看关于它的十个常识吧!</p> <p class="text-muted">阅读(2417) 评论(1) 赞(18) <span class='hidden-xs'>标签:健康 / 感染 / 指甲 / 疾病 / 皮肤 / 营养 / 趣味生活</span> </p> </div> <div class="col-sm-3 hidden-xs"> <img src="upload/3.jpg" alt=""> </div> </div> <div class="row"> <div class="col-sm-9"> <h3>生活馆 关于指甲的10个健康知识 你知道几个?</h3> <p class="text-muted hidden-xs">阿里佰秀 发布于2020-10-12</p> <p class='hidden-xs'>指甲时人身体上的关键部件,没了他,人就会受苦啊!别小看它,他就像铠甲一样可以保护人的指头,快看看关于它的十个常识吧!</p> <p class="text-muted">阅读(2417) 评论(1) 赞(18) <span class='hidden-xs'>标签:健康 / 感染 / 指甲 / 疾病 / 皮肤 / 营养 / 趣味生活</span> </p> </div> <div class="col-sm-3 hidden-xs"> <img src="upload/3.jpg" alt=""> </div> </div> <div class="row"> <div class="col-sm-9"> <h3>生活馆 关于指甲的10个健康知识 你知道几个?</h3> <p class="text-muted hidden-xs">阿里佰秀 发布于2020-10-12</p> <p class='hidden-xs'>指甲时人身体上的关键部件,没了他,人就会受苦啊!别小看它,他就像铠甲一样可以保护人的指头,快看看关于它的十个常识吧!</p> <p class="text-muted">阅读(2417) 评论(1) 赞(18) <span class='hidden-xs'>标签:健康 / 感染 / 指甲 / 疾病 / 皮肤 / 营养 / 趣味生活</span> </p> </div> <div class="col-sm-3 hidden-xs"> <img src="upload/3.jpg" alt=""> </div> </div> </div> </article> <aside class='col-md-3'> <a href="#" class='banner'> <img src="upload/zgboke.jpg" alt=""> </a> <a href="#" class="hot"> <span class="btn btn-primary">热搜</span> <h4 class='text-primary'>欢迎加入中国博客联盟</h4> <p class='text-muted'>这里有很多的东西呦!有很多优秀的博客,是一个全人工的编辑开放平台,用于交流与展示......</p> </a> </aside> </div> </div> </body> </html>
ul { list-style-type: none; margin: 0; padding: 0; } a { color: #666; text-decoration: none; } a:hover { text-decoration: none; } body { background-color: #f5f5f5; } .container { background-color: #fff; } /* 当尺寸大于1280px时,触发 */ @media screen and (min-width: 1280px) { .container { width: 1280px; } } /* header */ .logo { background-color: #429ad9; } .logo img { max-width: 100%; /* logo图片不需要缩放 */ margin: 0 auto; display: block; } .logo span { display: block; height: 50px; line-height: 50px; color: #fff; font-size: 18px; text-align: center; } header { padding-left: 0!important; padding-right: 0!important; } article { padding-right: 5px!important; } .nav { background-color: #eee; border-bottom: 1px solid #ccc; } .nav a { display: block; height: 50px; line-height: 50px; padding-left: 30px; } .nav a:hover { background-color: #fff; color: #333; } .nav a::before { vertical-align: middle; padding-right: 5px; } @media screen and (max-width: 991px) { .nav li { float: left; width: 20%; } article { margin-top: 10px; } } @media screen and (max-width: 767px) { .nav li a { font-size: 14px; padding-left: 0; } .news li:nth-child(1) { width: 100%!important; } .news li { width: 50%!important; } .publish h3 { font-size: 14px; } } .news li { width: 25%; float: left; height: 128px; padding-right: 10px; margin-bottom: 10px; } .news li a { width: 100%; height: 100%; display: block; background-color: lightgreen; position: relative; } .news li:nth-child(1) { width: 50%; height: 266px; } .news li:nth-child(1) p { line-height: 41px; padding: 0 10px; } .news li a img { width: 100%; height: 100%; } .news li a p { position: absolute; bottom: 0; left: 0; width: 100%; margin-bottom: 0; background-color: rgba(0, 0, 0, .5); font-size: 12px; color: #fff; height: 41px; padding: 5px 10px; } .publish { border-top: 1px solid #ccc; } .publish .row { border-bottom: 1px solid #ccc; } .publish img { margin-top: 10px; padding: 10px 0; width: 100%; } .banner img { width: 100%; } .hot { border: 1px solid #ccc; display: block; margin-top: 20px; padding: 0 20px 20px; } .hot span { border-radius: 0; margin-bottom: 20px; } .hot p { font-size: 12px; }