Grow:如何使用 flex-grow

在 doc 和 Bootstrap v4(here)的问题中,我看不到任何支持flex-grow的计划,例如这样的语法:

<div cl="d-flex">
      <div  cl="flex-grow">
        I use all the space left
      </div>
      <div>
        I am a small text on the right
      </div>
</div>

这里是我想创建的布局示例:

image

导出按钮始终位于右侧,导航按钮占用了所有剩余空间,因此看起来很干净。

是否有可能已经构建这样的布局?也许不建议?当然,有使用 CSS 的解决方法,但我正在寻找一个干净的解决方案,理想情况下使用 Bootstrap 类名只保证一致性。

45

使用.col作为简单的flex-grow: 1;。这里描述了https://v4-alpha.getbootstrap.com/layout/grid/#variable-width-content

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
<div cl="container">
  <div cl="row">
    <div cl="col">
      I use all the space left
    </div>
    <div cl="col-sm col-sm-auto">
      I am a small text on the right
    </div>
  </div>
</div>
43

对于任何人来到这里从谷歌搜索(像我一样)。

由于 Bootstrap v 4.1 有flex-growflex-shrink实用程序,因为documentation说你可以这样使用它们:

.flex-{grow|shrink}-0
.flex-{grow|shrink}-1
.flex-sm-{grow|shrink}-0
.flex-sm-{grow|shrink}-1

这里有一个小例子

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<div cl="d-flex flex-row">
  <div cl="d-flex flex-grow-1 text-white justify-content-center bg-danger">
    Grow 1
  </div>
  <div cl="d-flex flex-grow-0 text-white justify-content-center bg-success">
    Grow 0
  </div>
  <div cl="d-flex flex-grow-1 text-white justify-content-center bg-danger">
    Grow 1
  </div>
</div>
1

我为此创建了一个类,我检查了 Bootstrap 文档,没有发现任何东西。

.flex-2 { flex-grow: 2 }

col-auto占用剩余的空间,但是如果您有多行,则空间将不会平均分配。这就是为什么flex-grow可以做到这一点。

本站系公益性非盈利分享网址,本文来自用户投稿,不代表边看边学立场,如若转载,请注明出处

(191)
Kpd35国产k网站:可以在iPhone3GS上以35fps的速度获得超过20K+的三角形吗
上一篇
服务器接口:登录到 Serv-U服务器的HTTPS接口
下一篇

相关推荐

  • web服务与restful技术:使用RESTful API实现Web服务

    Web服务是一种软件系统,它可以通过网络与其他软件系统进行交互。它使用轻量级的、可扩展的协议,如HTTP,XML,JSON等,来支持远程服务调用和数据交换。…

    2023-02-17 15:20:28
    0 43 31
  • python安装urllib2:如何使用urllib2在Python中发送HTTP请求

    示例示例Python安装urllib2的方法:使用pip安装:…

    2023-02-10 15:57:27
    0 13 34
  • pinterest网页版在Pinterest上发现新的创意

    Pinterest网页版是一种社交媒体平台,它允许用户分享图片,视频,文章和其他内容。用户可以在Pinterest上创建自己的主页,收集和发布内容,并与其他用户进行交流。…

    2023-02-04 08:04:12
    0 67 36
  • winform选择文件夹“探索未知的世界”

    方法一:使用类在Form设计器中添加一个控件,名称可以自定义,如;…

    2023-02-05 03:48:57
    0 31 43
  • liferestart网页游戏改变你的未来

    LifeRestart是一款网页游戏,它的目的是让玩家重新开始生活,并在游戏中获得成功。游戏中有各种不同的任务,玩家可以通过完成任务来获得分数。游戏中也有一些难度较大的任务,这些任务可以帮助玩家更好地实现自己的目标。…

    2023-02-17 04:35:58
    0 17 22
  • Pis系统:用静态ip地址连接两个覆盆子pis(how to setup static ip on raspberry pi)

    关于Pis系统的问题,在how to setup static ip on raspberry pi中经常遇到,我想通过网络电缆连接两个 Raspberry Pis,以便将命令从一个 Pi 发送到另一个。为此,我想在两个 Pis 上设置一个静态 IP地址。我知道我将不得不编辑dhcpcd.conf-文件。…

    2022-11-23 08:53:12
    0 36 64
  • 射雕zero:RaspberryPiZero模拟鼠标

    关于射雕zero的问题,在raspberry mouse中经常遇到,我正在寻找一种方法来使用我的 Raspberry Pi Zero 作为 HID 鼠标。…

    2022-11-23 08:45:14
    0 99 85
  • 服务器接口:登录到 Serv-U服务器的HTTPS接口

    关于服务器接口的问题,在cookies must be enabled to use serv-u中经常遇到,我正在尝试通过代码 (C# / VB) 连接到企业 ftp 服务器。它已被设置为使用 SolarWinds Serv-U 软件在浏览器中运行,以便用户可以通过浏览器访问它。地址的形式为:…

    2022-11-23 08:43:38
    0 98 87

发表评论

登录 后才能评论

评论列表(38条)