美文网首页
bootstrap中container类和container-f

bootstrap中container类和container-f

作者: 寄居他乡 | 来源:发表于2019-07-22 08:49 被阅读0次

container和container-fluid到底什么区别。
查了很多资料,看到很多人和我有同样的疑问,但是下面的回答一般都是一个是固定宽度,一个宽度是百分百,说的好像是那么回事,但是你真的能明白吗?反正我是不能,于是我就去开始自己写demo

<!DOCTYPE html>
<html lang="zh-cn">
<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>Hello World</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">

</head>

<body>
    <div class="container">
        <h3>hello world</h3>
    </div>
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
</body>
</html>

写完之后打开浏览器,f12后发现container容器不止有15px的padding,还有一个会随着浏览器宽度变化而变化的margin,如图


image
image

上图的盒模型为我在满屏时的数值,对浏览器进行缩放会有增加或减少的变化,具体请自己试验,实践出真知嘛。
container-fluid demo
当把类换成container-fluid之后,你会发现页面有明显的变化
,如图


image
image

你会发现这次整个容器就只有固定的15px的padding,并没有再加margin。

结论
container 类和container-fluid类的区别体现在是否有随视口宽度改变的margin存在。
container类所谓的自适应也是通过margin的改变来完成,container-fluid类的百分百宽度是指在固有的15px的padding前提下宽度总是当前视口的宽度

相关文章

  • bootstrap中container类和container-f

    container和container-fluid到底什么区别。查了很多资料,看到很多人和我有同样的疑问,但是下面...

  • Bootstrap

    Bootstrap需要为页面内容和栅格系统包裹一个.container容器,框架中提供了两个类。.containe...

  • bootstrap的container容器和container-

    说到bootstrap的container容器和container-fluid容器的区别,我们可以通过一个实验来说...

  • 2018-09-29

    bootstrap 容器 container-fluid 流体 container 1170 970 750 10...

  • bootstrap栅格系统总结

    .container与.container_fluid是bootstrap中的两种不同类型的外层容器,按照官方的说...

  • container容器

    布局容器 Bootstrap需要为页面内容和栅格系统包裹一个.container容器,Bootstrap提供了两个...

  • 快牛科技-前端面试题

    1. bootstrap的布局是如何实现的?电脑端与手机端如何实现自适应? container类为相应...

  • Bootstrap属性含义合集

    Bootstrap属性含义合集 jumbotron会在container中形成一个灰色背景。 thumbnail可...

  • Bootstrap初学

    为什么前端不用Bootstrap 1.Bootstrap 引入 2.网格/栅栏系统 布局容器 .container...

  • bootstrap部分样式

    一. bootstrap-全局css样式-栅格布局系统 所有的行必须放在容器中.container或contain...

网友评论

      本文标题:bootstrap中container类和container-f

      本文链接:https://www.haomeiwen.com/subject/cozblctx.html