Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

html/js changing div style causes background image to disappear?

Hey HF, really strange issue here, I am working on a page, it contains multiple divs each with a background image and the following css

position: relative;
opacity: 1;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
min-height: 100%;
min-width: 100%;

each div can be hidden and shown with a button calling javascript that toggles div style to and from none/ block

however whenever a button is clicked the images disappear and just become white, any one have any idea why?

I can upload the script to a site if any one needs a closer look 🤝
I think I know what you're saying.
This is most likely because the container of the image is being set to an exact width/height.
As this element isn't being told to display none; it still shows the container but not the image on-toggling the button.
You would have to find the JS file and just display none on the whole container, instead of the img inside the container.

Hope that makes sense.
Web Designer / Developer & SEO Expert.

View Work
Earn 10% of the job you refer me to!

Skype aerox.design


(Aug 19, 2017 12:52 PM)Rushax Wrote:  I think I know what you're saying.
This is most likely because the container of the image is being set to an exact width/height.
As this element isn't being told to display none; it still shows the container but not the image on-toggling the button.
You would have to find the JS file and just display none on the whole container, instead of the img inside the container.

Hope that makes sense.

Hey thanks for the reply, I managed to fix my issue by setting the background image in the css for the div, where before it was set like this
<div id="id" class="class" style='background-image: url("Images/image.png");'

all working now, thanks 🤝


Possibly Related Threads...
Thread / Author Replies Views Last Post
by oxagastSep 3, 2022 07:52 AM 0 197 Sep 3, 2022 07:52 AM
Last Post: oxagast
by EffexionApr 15, 2021 05:12 AM 10 278 Apr 15, 2021 05:12 AM
Last Post: Goku
by CarrotDec 24, 2020 12:16 PM 0 244 Dec 24, 2020 12:16 PM
Last Post: Carrot