background image using html inline styles is not working
See original GitHub issueThis a 🐛 bug report
I’m trying to use HTML inline styles to show a background image to a div. This is done inside HTML
code directly.
🎛 Configuration (package.json)
"scripts": {
"start": "parcel index.html"
}
🤔 Expected Behavior
I expect images to work using the inline style background image even if the URL is local
😯 Current Behavior
the image does not appear and
When i open the URL of the image ‘localhost:1234/images/image.jpg’
it is like opening localhost:1234
This only happens when I use a local image, if I use an image URL, it works normally.
💁 Possible Solution
images works using the inline style background image even if the URL is local
🔦 Context
Im trying to use an image slider that fills the whole window. That is why i need to inline image background URLs inside HTML
💻 Code Sample
This does not work
<div class='bg' style="background: url('./images/april-2015.jpg') no-repeat center center fixed"></div>
This works
<div class='bg' style="background: url(http://news.images.itv.com/image/file/626702/img.jpg) no-repeat"></div>
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | latest |
Node | latest |
npm | latest |
Mac |
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Inline CSS background-image not displaying - Stack Overflow
The developer view in my browser shows that the image and CSS file are linked correctly, but nothing is displaying. Any help greatly...
Read more >How to fix CSS background-image not working | HTML/CSS
1. Check that your CSS file is linked correctly in your HTML file. · 2. Make sure the image path is set correctly...
Read more >CSS Background Image Not Working - Position Is Everything
If the CSS file is not properly linked to the HTML file, the background would be white and not show any style or...
Read more >background-image - CSS: Cascading Style Sheets | MDN
The background-image CSS property sets one or more background images on an element.
Read more >CSS background-image property - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
a local background image won’t work with external css either .
<div class="img-banner" :style="{'background-image': 'url(' + require('./assets/media/baner1.jpg') + ')'}"></div>