【问题标题】:Background image Sass, Css and Express背景图片 Sass、Css 和 Express
【发布时间】:2022-01-23 04:45:30
【问题描述】:

为什么当我在我的 .scss 中这样做时:

.section-home{
 background-image: url(Yggdrasil.jpg);
 position: relative;
 min-height: 100vh;
 background-size: cover;
 background-position: center;
 display: flex;
 justify-content: center;
 align-items: center;
}

我运行命令 yarn watch,在相关文件 .css 中我有这个代码:

.section-home {
  background-image: url(/images/Yggdrasil.jpg?71322804ce7f3cec49ab9190e347b8a6);
  position: relative;
  min-height: 100vh;
  background-size: cover;
  background-position: center;
  display: flex;
  justify-content: center;
  align-items: center;
}

【问题讨论】:

  • 你能澄清一下你的问题吗?
  • 为什么在css中改路径,图片看不到?
  • 图像与代码文件的关系在哪里?您如何提供代码?
  • 图片在 .scss 的同一个文件夹中,当我运行 yarn watch 时,它会用图片创建一个文件夹图片,在 css 文件中,名称后跟 ?.....
  • 在 webpack.mix.js 中,我有这行代码: mix.js('resources/js/app.js', 'public/js/app.js').sass( 'resources/scss/app.scss', 'public/css/app.css');

标签: css reactjs express sass


【解决方案1】:

我解决了。在 webpack.mix.js 文件中,我添加了这行代码:

mix.sass('resources/scss/app.scss', 'public/css/app.css').options({
    processCssUrls: false
});

因为我使用 laravel-mix。关注这个doc

【讨论】:

    猜你喜欢
    • 2019-09-25
    • 2014-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-24
    • 2015-03-13
    • 2018-09-29
    • 1970-01-01
    相关资源
    最近更新 更多