gpt4 book ai didi

twitter-bootstrap - 如何使用 CDN 在 bootstrap 4 中创建新断点?

转载 作者:行者123 更新时间:2023-12-03 20:16:12 25 4
gpt4 key购买 nike

我使用 BootstrapCDN。其他用 sass 编写并由 gulp 构建的样式。我需要创建自己的断点。如果我使用 CDN,是否可以制作它们?我不知道该怎么做。我必须创建这些断点:

--breakpoint-xxxs: 0;
--breakpoint-xxs: 320px;
--breakpoint-xs: 568px;
--breakpoint-sm: 667px;
--breakpoint-md: 768px;
--breakpoint-lg: 992px;
--breakpoint-xl: 1200px;
--breakpoint-xxl: 1440px;
--breakpoint-xxxl: 1600px;

我想得到这样的东西:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<div class="container">
<div class="row">
<div class="col col-xxxs-1 col-xxs-2 col-xs-3 col-sm-4 col-md-5 col-lg-6 col-xl-7 col-xxl-8 col-xxxl-9">
<div style="height:100vh;background:purple">text</div>
</div><!--col-->
</div><!--.row-->
</div><!--.container-->


我找到了 the manual我正在尝试这个:
$grid-breakpoints: (
xxxs: 0,
xxs: 320px,
xs: 568px,
sm: 667px,
md: 768px,
lg: 992px,
xl: 1200px,
xxl: 1440px,
xxxl: 1600px
) !default;

$container-max-widths: (
xxxs: 0,
xxs: 320px,
xs: 568px,
sm: 667px,
md: 768px,
lg: 992px,
xl: 1200px,
xxl: 1440px,
xxxl: 1600px
) !default;

:root {
--breakpoint-xxxs: 0;
--breakpoint-xxs: 320px;
--breakpoint-xs: 568px;
--breakpoint-sm: 667px;
--breakpoint-md: 768px;
--breakpoint-lg: 992px;
--breakpoint-xl: 1200px;
--breakpoint-xxl: 1440px;
--breakpoint-xxxl: 1600px;
}

但它不会产生结果,并产生错误:

Illegal nesting: Nothing may be nested beneath variable declarations.



Codepen mcve .

我做错了什么?
预先感谢您的帮助。

UPD:如果那不可能……还有其他选择吗?我可以轻松地编辑我的代码以使用我的断点模拟 Bootstrap 网格吗?

UPD2:感谢 @aer0,我修复了错误:
$grid-breakpoints: (xxxs: 0, xxs: 320px, xs: 568px, sm: 667px, md: 768px, lg: 992px, xl: 1200px, xxl: 1440px, xxxl: 1600px)!default

$container-max-widths: (xxxs: 0, xxs: 320px, xs: 568px, sm: 667px, md: 768px, lg: 992px, xl: 1200px, xxl: 1440px, xxxl: 1600px)!default

\:root
--breakpoint-xxxs: 0
--breakpoint-xxs: 320px
--breakpoint-xs: 568px
--breakpoint-sm: 667px
--breakpoint-md: 768px
--breakpoint-lg: 992px
--breakpoint-xl: 1200px
--breakpoint-xxl: 1440px
--breakpoint-xxxl: 1600px

但这并不能解决我的问题。

最佳答案

它不能完全从 CDN 完成。要使用 SASS 正确自定义/覆盖,您需要在 custom.scss 中 @import 必要的 Bootstrap scss 文件。 .要覆盖网格断点,您至少需要 functionsvariables .然后根据需要设置变量,最后@import bootstrap。注意默认!已被删除为 explained in the docs作为正确的定制方法。

/* import what we need to override */
@import "bootstrap/functions";
@import "bootstrap/variables";

/* set the overriding variables */
$grid-breakpoints: (
xxxs: 0,
xxs: 320px,
xs: 568px,
sm: 667px,
md: 768px,
lg: 992px,
xl: 1200px,
xxl: 1440px,
xxxl: 1600px
);
$container-max-widths: (
xxxs: 0,
xxs: 320px,
xs: 568px,
sm: 667px,
md: 768px,
lg: 992px,
xl: 1200px,
xxl: 1440px,
xxxl: 1600px
);

/* override the !default vars with the values we set above */
@import "bootstrap";

通过这种方法,我们添加了新的网格断点,并确保了 这些新断点无处不在在 Bootstrap 中,包括 网格,用于间距、显示、弹性框、对齐、定位的响应式实用程序 , ETC...

https://codeply.com/go/BIgmm1XGc2

另见:
How to extend/modify (customize) Bootstrap 4 with SASS
Twitter Bootstrap: add media queries for xxs breakpoint

关于twitter-bootstrap - 如何使用 CDN 在 bootstrap 4 中创建新断点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48924751/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com