create react app not loading css background images in dev or build

旧时模样 提交于 2019-12-04 04:29:00

The issue was purely an issue with CSS in the App.css file:

App.css

.trees__tree {    
    background: url('../images/tree.png') no-repeat;
    background-size: 30px; /** moved this property down */
    float: left;
    height: 50px;
    width: 30px;
}

My issue was specifically that I did not have background-size: 30px; defined. Thanks for this.

abhinav tyagi

Add homepage in package.json to run build in any apache server

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "homepage": "http://{servername}/{foldername}/",

}

then create build in react using

  1. npm run build
  2. npm install -g serve
  3. serve -s build
  4. Copy build folder and paste in server like xampp/htdocs and hit url
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!