简体   繁体   English

Webp背景图像未在生产中显示

[英]Webp background image not showing in production

In my project I wanted the background image from jpg to webp.在我的项目中,我想要从 jpg 到 webp 的背景图像。 In development I don't get any problems and the image shows up correctly, like in this image .在开发中,我没有遇到任何问题,并且图像正确显示,就像在这个图像中一样。 But if I access the site from its link (hosted with AWS) the image is not loaded (the background is simply gray like on the other pages) in any browser (I tried Chrome and Edge and also from mobile).但是,如果我从其链接(由 AWS 托管)访问该站点,则在任何浏览器(我尝试过 Chrome 和 Edge 以及移动设备)中都不会加载图像(背景只是像其他页面上的灰色)。

Here is the code where the image is:这是图像所在的代码:

import styled from 'styled-components';
import backgroundImage from '../../assets/images/background.webp';

export const PageContainer = styled.div`
    height: 100%;
    background: url(${backgroundImage}) no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background-position-y: 60%;
`;

Here the github repo and the live site .这里是github repo和 live site

You just need to check your error in inspect of your browser and probably your file address is wrong or you forgot to upload that.您只需要在检查浏览器时检查您的错误,并且您的文件地址可能是错误的,或者您忘记上传了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM