简体   繁体   中英

Background-image url() doesn't work but image tag with src does

currently working in vue 3 and tailwind css, the path works with src but not with url, I have exhausted all the information I can find but can't seem to figure out the problem, I believe the file path must be correct since src is able to locate it

<template>
  <div
    class="absolute top-0 w-full h-full bg-center bg-cover"
    style="background-image: url(../assets/images/unsplash.png)"
  >
    <span id="blackOverlay" class="w-full h-full absolute opacity-75 bg-black"></span>
   <div>
     <img src="../assets/images/unsplash.png" alt="">
   </div>
  </div>
</template>

The url to the image should be into simple quotes :) Try this :

style="background-image: url('../assets/images/unsplash.png')"

Sincerely, Alex ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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