bootstrap入门(三)栅格系统

布局

在bootstrap中 响应式布局通过栅格系统达成的。
栅格系统主要构成元素 row 和 col (column)
有点像 Excel 单元格
一行最大允许12格的长度,超过12格长度就跳到下面一行
行定义用

<div class="row">div>

列定义用

 <div class="col-针对哪种设备-长度">asdsadiv>

设备:
bootstrap入门(三)栅格系统_第1张图片
图片来自
http://www.runoob.com/bootstrap/bootstrap-grid-system.html


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Documenttitle>
    
    <link rel="stylesheet" type="text/css" href="./css/bootstrap.min.css" >
    <script src="./js/jquery-3.3.1.min.js">script>
    <script src="./js/bootstrap.min.js">script>
head>
<body>
    <div class="container">
            <div class="row">
                    <div class="col-md-6" style="background: #6666cc">adiv>
                    <div class="col-md-6" style="background: #66ccff">bdiv>
            div>
    div>


body>
html>

给div添加多个class就能达到自适应的效果


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Documenttitle>
    
    <link rel="stylesheet" type="text/css" href="./css/bootstrap.min.css" >
    <script src="./js/jquery-3.3.1.min.js">script>
    <script src="./js/bootstrap.min.js">script>
head>
<body>
    <div class="container">
            <div class="row">
                    <div class="col-md-6 col-xs-8" style="background: #6666cc">adiv>
                    <div class="col-md-6 col-xs-4" style="background: #66ccff">bdiv>
            div>
    div>


body>
html>

调整浏览器大小看看
bootstrap入门(三)栅格系统_第2张图片

嵌套

div嵌套: 子div能达到的最大宽度为父div的宽度


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Documenttitle>
    
    <link rel="stylesheet" type="text/css" href="./css/bootstrap.min.css" >
    <script src="./js/jquery-3.3.1.min.js">script>
    <script src="./js/bootstrap.min.js">script>
head>
<body>
    <div class="container">
            <div class="row">
                    <div class="col-md-6 col-xs-8" style="background: #6666cc">
                        <div class="col-md-6" style="background: #5e5e5e">cdiv>
                        <div class="col-md-6" style="background: red">ddiv>
                    div>

                    <div class="col-md-6 col-xs-4" style="background: #66ccff">bdiv>
            div>
    div>
body>
html>

你可能感兴趣的:(bootStrap)