博客系统 - 系统简介与首页设计
来源:头歌教学平台
第一关:
本关任务:用Bootstrap
实现PC
端的博客头部效果。
编程要求
在右侧代码框中,填充begin
至end
之间的代码,完成博客首页在中等屏幕下头部的效果,要求如下:
-
logo
部分占2
格,没有列偏移; -
首页-资源部分占
4
格,没有列偏移; -
搜索框部分占
3
格,没有列偏移; -
登陆注册部分占
2
格,向右偏移1格。
注:这里约定类的顺序,先写占的格数,再写列偏移。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>博客</title>
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.2/css/bootstrap.min.css">
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
</head>
<body>
<div class="bg">
<div class="container">
<div class="row header">
<!-----请仔细阅读Begin-End之间的代码,补充双引号" "间缺失的代码------>
<!--------- Begin ---------->
<!--logo部分-->
<div class="col-md-2">
<a href="#">
<img src="https://data.educoder.net/attachments/download/204880" alt="logo" style="width:80px;">
</a>
</div>
<!--首页-资源部分-->
<div class=" col-md-4 ">
<a href="#" class="nav-item">首页</a>
<a href="#" class="nav-item">代码库</a>
<a href="#" class="nav-item">问答</a>
<a href="#" class="nav-item">资源</a>
</div>
<!--搜索框部分-->
<div class=" col-md-3 ">
<form class="search">
<div class="form-group has-feedback">
<input type="text" class="form-control" id="search" aria-describedby="searchStatus" placeholder="搜索">
<span class="glyphicon glyphicon-search form-control-feedback" aria-hidden="true"></span>
</div>
</form>
</div>
<!--登陆注册部分-->
<div class="col-md-2 col-md-offset-1">
<a href="#" class="nav-item">登录</a>
<a href="#" class="nav-item">注册</a>
</div>
<!---------- End ---------->
</div>
</div>
</div>
</body>
</html>
<style>
body {
background: #eee;
}
.bg {
width: 100%;
background: #fff;
margin-bottom: 20px;
}
.header {
background: #fff;
line-height: 70px;
}
.header .search {
margin-top: 20px;
}
.header .nav-item {
padding: 8px;
font-size: 18px;
}
</style>
第一关知识点内容分析:
各种屏幕下列的类前缀:
超小屏幕(<768px ) | 小屏幕(>=768px ) | 中等屏幕(>=992px ) | 大屏幕(>=1200px ) | |
---|---|---|---|---|
列的类前缀 | .col-xs- | .col-sm- | .col-md- | .col-lg- |
可以发现:列名的组成结构: col + 表示屏幕大小的英文 + 占的格数。比如:在中等屏幕下占了4
格,表示如下:
.col-md-4
登录注册的另一个类:.col-md-offset-1
,这个类表示中等屏幕下列向右偏移1
格,相当于增加了登录注册的左侧边距(margin
)。12
格是占满的。
举一反三:列偏移就是在列名中间加了 offset
,比如小屏幕下向右偏移3
格,写法如下:
.col-sm-offset-3