【问题标题】:Overriding inline CSS in next js sass module在下一个 js sass 模块中覆盖内联 CSS
【发布时间】:2021-02-21 00:49:46
【问题描述】:

我使用 Twemoji 库在我的 Next js 应用程序中获取表情符号图标,它们在最终 HTML 中显示为 <span><img></span>,我可以在我的 globals.scss 文件中使用 !important 覆盖它们的默认宽度和高度:

.customize { //Parent class containers 3 buttons, each one has an emoji element
    top: 88%;
    right: calc(50vw - (52.2px + 3rem));
    button {
      span img[style]{
        width: 35px !important;
        height: 35px !important;
      }
    }
  }

然后我尝试将其提取为[].module.scss 文件,一切正常,但图像大小没有任何变化。为什么?

编辑 这是我要设置样式的组件:

import ThemeButton from '../components/themeCustomizeButton' // a button that renders an emoji
import LanguageSwitcher from '../components/LanguageSwitch' // a button that renders an emoji
import Complex from '../components/ComplexitySwitch' // a button that renders an emoji
import styles from "../styles/local/components/customize.module.scss" // importing .module.scss

function Customizing() {
    return(
        <section className={styles.customize}>
            <ThemeButton />
            <LanguageSwitcher />
            <Complex />
        </section>
    )
}

export default Customizing

【问题讨论】:

  • 你是如何应用 Sass 模块中的样式的?你能分享你在那个组件中的代码吗?
  • @juliomalves 我将组件添加到问题中

标签: html css next.js css-modules


【解决方案1】:

在您尝试提取的任何位置之前使用此代码

$(document).ready(function () {  
  // Set the size of the rendered Emojis
  // This can be set to 16x16, 36x36, or 72x72
  twemoji.size = '36x36';

});

【讨论】:

  • 我不想在我的 Next.js 应用程序中使用 jquery。并且表情符号的大小会根据窗口宽度动态变化。
猜你喜欢
  • 2014-09-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-16
  • 2019-12-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多