Bootstrap front-end development framework use

Bootstrap front-end development framework

Recommended learning URL

Bootstrap use

1. Suggested directory structure

Insert picture description here

2. HTML skeleton

<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
     <!--[if lt IE 9]>
      <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/html5shiv.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/[email protected]/dest/respond.min.js"></script>
    <![endif]-->
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
  </head>
  <body>
    内容
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
  </body>
</html>

3. Raster prefix classification

~ Ultra small screen (mobile phone)
<768px
Small screen device (tablet)
>=768px
Medium screen (PC)
>=992px
Widescreen device
>=1200px
.container maximum width Automatic (100%) 750px 970px 1170px
Class prefix .col-xs- .col-sm- .col-md- .col-lg-

4. Grid nested table (pay attention to details)

<div class="row">
        <div class="col-md-4">
            <!-- 最好增加row行,这样可以取消父元素的padding,且高度和父级一样 -->
            <div class="row">
                <!-- 也是将父容器分12等分 -->
                <div class="col-md-6">a</div>
                <div class="col-md-6">b</div>
            </div>
        </div>
        <div class="col-md-4">2</div>
        <div class="col-md-4">3</div>
    </div>

Insert picture description here

5. Grid-column offset

   <div class="container">
        <div class="row">
            <div class="col-md-4">左侧</div>
            <div class="col-md-4 col-md-offset">右侧</div>
        </div>
        <div class="row">
            <div class="col-md-8 col-md-offset-2">中间</div>
        </div>
    </div>

Insert picture description here

6. Grid-column sorting

   <div class="container">
        <div class="row">
            <!-- 将左侧的盒子-推到右侧8个位置 -->
            <div class="col-md-4 col-md-push-8">左侧</div>
            <!-- 将右侧的盒子-拉回右侧4个位置 -->
            <div class="col-md-4 col-md-pull-4">右侧</div>
        </div>
    </div>

Insert picture description here

7. Responsive tools

Class name Hide screen size
.hidden-xs Ultra small screen
.hidden-sm Small screen
.hidden-md Middle screen
.hidden-lg Big screen

Instead, the class name: visible-xs visible-sm visible-md visible-lg

8. Modify the maximum width of the container to 1280px

@media screen and (min-width:1280px){
    .container{
        width: 1280px;
    }
}

9. Use of icons

// 直接复制图标编码到对应元素
<div class="nav">
    <a href="#" class="glyphicon glyphicon-camera">照相机</a>
</div>

The effect is as follows:
Insert picture description here
adjust the style:

.nav a::before{
    vertical-align: middle;
    padding-right: 5px;
}

The effect is as follows:
Insert picture description here

Guess you like

Origin blog.csdn.net/Asia1752/article/details/109255406