花了一天时间仿照完成,这个网站是很出名的bootCDN中文网,通观整个网页,其布局主要用到了,nav,jumbotron,list-group,最主要的就是container类,对于我来说,也还算是简单,现将代码发到博客供自己学习总结,如有侵犯,马上删除:
源网页链接:https://www.bootcdn.cn/
总结:
1.input框设置宽度并居中:将整个form-grop包裹在一个容器sreah-wraper中,并对齐样式进行设置:
.jumbotron .container .row .sreah-wraper {
max-width: 680px;
margin-left: auto;
margin-right: auto;
margin-top: 30px;
margin-bottom: 20px;
html代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
<!-- Bootstrap -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.css">
<link rel="stylesheet" href="style.css">
<!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询(media queries)功能 -->
<!-- 警告:通过 file:// 协议(就是直接将 html 页面拖拽到浏览器中)访问页面时 Respond.js 不起作用 -->
<!--[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]-->
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a href="" class="navbar-brand">BootCDN</a>
<button class="navbar-toggle" data-toggle="collapse" data-target=".collapse">
<span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse navbar-right">
<ul class="nav navbar-nav">
<li><a href="#">API</a></li>
<li><a href="#">博客</a></li>
<li><a href="#">关于</a></li>
</ul>
</div>
</div>
</nav>
<!-- 超大屏幕 -->
<div class="jumbotron text-center">
<div class="container">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<h1>BootCDN</h1>
<p>稳定、快速、免费的前端开源项目 CDN 加速服务</p>
<p>共收录了<strong>3409</strong>个前端开源项目</p>
<div class="sreah-wraper" role="sreah">
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control input-lg" placeholder="Searh">
<span class="input-group-btn">
<button type="submit" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 图片列表 -->
<div class="well text-center hidden-sm hidden-xs">
<div class="container tupian">
<div class="row">
<div class="col-md-12">
<ul class="list-inline">
<li><a href="#"><img src="images/pic1.svg" alt=""></a></li>
<li><a href="#"><img src="images/pic2.svg" alt=""></a></li>
<li><a href="#"><img src="images/pic3.svg" alt=""></a></li>
<li><a href="#"><img src="images/pic4.svg" alt=""></a></li>
<li><a href="#"><img src="images/pic5.svg" alt=""></a></li>
<li><a href="#"><img src="images/pic6.svg" alt=""></a></li>
<li><a href="#"><img src="images/pic7.svg" alt=""></a></li>
<li><a href="#"><img src="images/pic8.svg" alt=""></a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container hidden-sm hidden-xs ">
<a href="#" class="pull-right">拒绝流量劫持,全面使用HTTPS!</a>
</div>
</div>
<!-- 一系列链接表 -->
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="list-group">
<a href="#" class="list-group-item">
<div class="row">
<div class="col-md-3 col-sm-12">
<h4>twitter-bootstrap</h4>
</div>
<div class="col-md-9 col-sm-12">
<p class="hidden-xs">Bootstrap 是全球最受欢迎的前端组件库,用于开发响应式布局、移动设备优先的 WEB 项目。</p>
<span class="glyphicon glyphicon-star">11111</span>
</div>
</div>
</a>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="list-group">
<a href="#" class="list-group-item">
<div class="row">
<div class="col-md-3 col-sm-12">
<h4>twitter-bootstrap</h4>
</div>
<div class="col-md-9 col-sm-12">
<p class="hidden-xs">Bootstrap 是全球最受欢迎的前端组件库,用于开发响应式布局、移动设备优先的 WEB 项目。</p>
<span class="glyphicon glyphicon-star">11111</span>
</div>
</div>
</a>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="list-group">
<a href="#" class="list-group-item">
<div class="row">
<div class="col-md-3 col-sm-12">
<h4>twitter-bootstrap</h4>
</div>
<div class="col-md-9 col-sm-12">
<p class="hidden-xs">Bootstrap 是全球最受欢迎的前端组件库,用于开发响应式布局、移动设备优先的 WEB 项目。</p>
<span class="glyphicon glyphicon-star">11111</span>
</div>
</div>
</a>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="list-group">
<a href="#" class="list-group-item">
<div class="row">
<div class="col-md-3 col-sm-12">
<h4>twitter-bootstrap</h4>
</div>
<div class="col-md-9 col-sm-12">
<p class="hidden-xs">Bootstrap 是全球最受欢迎的前端组件库,用于开发响应式布局、移动设备优先的 WEB 项目。</p>
<span class="glyphicon glyphicon-star">11111</span>
</div>
</div>
</a>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="list-group">
<a href="#" class="list-group-item">
<div class="row">
<div class="col-md-3 col-sm-12">
<h4>twitter-bootstrap</h4>
</div>
<div class="col-md-9 col-sm-12">
<p class="hidden-xs">Bootstrap 是全球最受欢迎的前端组件库,用于开发响应式布局、移动设备优先的 WEB 项目。</p>
<span class="glyphicon glyphicon-star">11111</span>
</div>
</div>
</a>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="list-group">
<a href="#" class="list-group-item">
<div class="row">
<div class="col-md-3 col-sm-12">
<h4>twitter-bootstrap</h4>
</div>
<div class="col-md-9 col-sm-12">
<p class="hidden-xs">Bootstrap 是全球最受欢迎的前端组件库,用于开发响应式布局、移动设备优先的 WEB 项目。</p>
<span class="glyphicon glyphicon-star">11111</span>
</div>
</div>
</a>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="list-group">
<a href="#" class="list-group-item">
<div class="row">
<div class="col-md-3 col-sm-12">
<h4>twitter-bootstrap</h4>
</div>
<div class="col-md-9 col-sm-12">
<p class="hidden-xs">Bootstrap 是全球最受欢迎的前端组件库,用于开发响应式布局、移动设备优先的 WEB 项目。</p>
<span class="glyphicon glyphicon-star">11111</span>
</div>
</div>
</a>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="list-group">
<a href="#" class="list-group-item text-center">获取开源项目...</a>
</div>
</div>
</div>
</div>
<!-- footer -->
<div class="footer">
<div class="container">
<div class="row">
<div class="col-md-5 col-sm-12">
<h4>关于 BootCDN</h4>
<p>BootCDN 是 <a href=""> Bootstrap中文网</a>支持并维护的前端开源项目免费 CDN 服务,致力于为 Bootstrap、jQuery、Angular、Vuejs 一样优秀的前端开源项目提供稳定、快速的免费 CDN 加速服务。BootCDN 所收录的开源项目主要同步于 <a href="">cdnjs</a> 仓库。</p>
<p>自2013年10月31日上线以来已经为50多万家网站提供了稳定、可靠的免费 CDN 加速服务。</p>
<p>反馈或建议请发送邮件至:cdn@bootcss.com</p>
</div>
<div class="col-md-3 col-sm-12">
<h4>友情链接</h4>
<p>
<a href="#">Bootstrap中文网</a>
<a href="#">Ghost中国</a>
</p>
<p>
<a href="#">Laravel中文网</a>
<a href="#">jQuery中文文档</a>
</p>
<p>
<a href="#">Webpack中文网</a>
<a href="#">NPM中文网</a>
</p>
<p>
<a href="#">全栈课堂</a>
<a href="#">91PHP</a>
<a href="#">Node.js中文文档</a>
</p>
</div>
<div class="col-md-2 col-sm-12">
<h4>我们用到的技术</h4>
<ul class="list-unstyled list-inline">
<li><a href="#">Bootstrap</a></li>
<li><a href="#">Ghost</a></li>
<li><a href="#">jQuery</a></li>
<li><a href="#">Babeljs</a></li>
<li><a href="#">Lodash</a></li>
<li><a href="#">Node.js</a></li>
<li><a href="#">Grunt</a></li>
<li><a href="#">Gulp</a></li>
<li><a href="#">NPM</a></li>
<li><a href="#">webpack</a></li>
<li><a href="#">Rollup</a></li>
<li><a href="#">Parcel</a></li>
<li><a href="#">PostCSS</a></li>
</ul>
</div>
<div class="col-md-2 footer-last col-sm-12">
<h4>CDN赞助商</h4>
<a href="#">
<img src="images/pic9.svg"></immg>
</a>
</div>
</div>
</div>
<div class="footer-dibu well col-sm-12 col-sm-12 col-xs-12">
<span>© 2013-2018 </span>
<a href="#">京ICP备11008151号 </a>
<span>京公网安备11010802014853</span>
</div>
</div>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery,所以必须放在前边) -->
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
css代码如下:
body {
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
.navbar {
margin: 0;
background: #27AE60;
border: 0;
box-shadow: none;
border-radius: 0;
}
.navbar .container .navbar-header .navbar-brand {
color: #FFFFFF;
}
.navbar .container .navbar-header .navbar-toggle {
border-color: #27AE60;
}
.navbar .container .navbar-header .navbar-toggle .icon-bar {
background: white;
}
.navbar .container .navbar-collapse .navbar-nav li a {
color: #FFFFFF;
}
.navbar .container .navbar-collapse {
border-color: #3BB56F;
}
.jumbotron {
background: #27AE60;
color: #FFFFFF;
margin-bottom: 0;
}
.jumbotron .container .row .col-md-6 .form {
margin-left: 30px;
}
.jumbotron .container .row .sreah-wraper {
max-width: 680px;
margin-left: auto;
margin-right: auto;
margin-top: 30px;
margin-bottom: 20px;
}
.well {
padding: 9px 9px 9px 9px;
}
.well .container .row .col-md-12 .list-inline {
margin: 0;
}
.well .container .row .col-md-12 .list-inline li a img{
width: 32px;
margin-right: 38px;
}
.container .row .col-md-12 .list-group {
margin-bottom: 0;
}
.container .row .col-md-12 .list-group .list-group-item {
border-bottom: none;
border-radius: 0;
}
.footer{
background: #27AE60;
color: #FFFFFF;
}
.footer .row a {
border-bottom: dotted 1px #a9dfbf;
color: #FFFFFF;
font-size: 14px;
line-height: 1.42857143;
}
.footer .row .footer-last a {
border-bottom: none;
}
.footer-dibu {
margin: 0;
text-align: center;
background: #28A45C;
border-color: #28A45C;
}
.footer-dibu a{
color: #ffffff;
border-bottom: dotted 1px #a9dfbf;
}
效果图如下: