【问题标题】:Foundation 6 - breakpoint Mixin - "medium" not correctly setFoundation 6 - 断点 Mixin - “medium”未正确设置
【发布时间】:2017-07-29 08:34:00
【问题描述】:

我尝试为中等屏幕和更小的屏幕设置不同的字体大小:

// _settings.scss

$global-font-size: 100%;
$global-width: rem-calc(1000);
$breakpoints: (
    small: 0px,
    medium: 640px,
    large: 1000px
);


// _header.scss

.top-bar-left {

    h1 {
        font-size: 1.5rem;

        @include breakpoint(medium down) {
            font-size: 3rem;
        }
    }
}

生成以下 CSS:

@media screen and (max-width: 62.4375em)
.top-bar .top-bar-left h1 {
    font-size: 3rem;
}

这是问题所在,因为我想要中等大小(640px 40em 而不是 62.5em)。

我是不是忘记了什么?也许在我的设置中?

更新

我的 sass 入口文件:

@charset 'utf-8';

@import 'settings';
@import '../node_modules/foundation-sites/scss/foundation';

/**
 * Foundation 6
 */
@include foundation-everything;

/**
 * App
 */
@import 'base';
@import 'header';
@import 'homepage';

【问题讨论】:

    标签: css responsive-design zurb-foundation


    【解决方案1】:

    原因是您将断点设置为“所有中等”==> 640px 到 1000px 和“所有小”==> 0px 到 640px。因此最大宽度 = 62.4375em 或 16 * 62.4375em = 999px。

    如果您的目标是“从 640 像素以下”,那么您只需要:

    @include breakpoint(small only) {
        font-size: 3rem;
    }
    

    应该评估为:

    @media screen and (max-width: 39.9375em) {
        font-size: 3rem;
    }
    

    其中 39.9375em * 16 = 639px。

    编辑 或者,您可以使用断点功能:

    @media screen and #{breakpoint(small only)} {
        font-size: 3rem;
    }
    

    【讨论】:

    • 感谢您的回答。我用@include breakpoint(medium only) { font-size: 3rem }测试,生成的CSS是@media screen and (max-width: 62.4375em) and (min-width: 40em)。然后我尝试了您的修复(small only),但没有生成 CSS:s
    • 您在构建时是否遇到错误?类似:WARNING: breakpoint(): "small" is not defined in your $breakpoints setting. 我在上面添加了另一种方法,但基本相同。
    • 相同的行为...我更新了我的问题 sass 条目文件,这是 _settings.scssgist.github.com/aguidis/234bdcbb8fb4fd1b54f8ff45dd167ae2
    • 我不完全确定这很重要,但在原始的_settings.scss 文件中,$breakpoints: 设置在最后一行的末尾有一个,(他们的所有列表似乎都如此)。
    • 与昏迷的行为相同。当我使用small 断点时没有生成CSS...我不明白^^'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-11
    • 1970-01-01
    • 2013-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-02
    相关资源
    最近更新 更多