I've made a parallax effect in CSS. to achieve this effect I have set a background-image in css. Now I would like to implement this in my Umbraco site.
Is there a way to make this dynamic? So my client could change the image easily in the Back-office.
Dynamic CSS images
Hi Everyone,
I've made a parallax effect in CSS. to achieve this effect I have set a background-image in css. Now I would like to implement this in my Umbraco site.
Is there a way to make this dynamic? So my client could change the image easily in the Back-office.
Thanks in advance, Gerben
Do you want to make it so that the user can change the parallax image?
What version of Umbraco are you using?
Thank you very much for your quick reply.
Exactly. My client would like to change the parallax image. I'm using Umbraco 7.6.3.
I look forward to your reply
Gerben
You will need to create a property editor for the page which is having the dynamic image in the CMS, as a single media picker.
After uploading an image you can then insert it directly into the styling.
Set the background-image: url() on the view, using inline CSS. You can then use Razor to insert the CMS image into the CSS style.
Example:
Please let me know if you need more detail or this doesn't work.
Hi Alex,
I would like to thank you for your quick reply.
Your solution worked beautifly. Thank you so much. i really appreciate it.
kind regards, Gerben
Comment author was deleted
I would like to add a question here:
I would like to insert a background image on a class:after. Is it even possible?
css:
My problem is that I would like to use this fix: https://stackoverflow.com/questions/28710659/css-background-image-on-top-of-img because I currently have a problem when I want to apply a filter grayscale and my div background image suddenly switch on the second floor.
Thank you
Hi,
Happy to be corrected but as far as I know the only way to do this would be with some on page css in your template.
Umbraco doesn't get involved in the serving of your CSS so razor tags won't work. I'm not sure if you could / should try and make it do it.
HTH
Steve
Comment author was deleted
do you suggest to insert a JS function to add the ":after" css at the end of the charge of the page? would it work as the css is charged before?
You could do it by JS or your could just write out the CSS rule in your cshtml template / partial and use razor to output the image from the picker.
I hate these sort of hacks but I'm yet to find a suitable workaround.
Comment author was deleted
Will try and see if it works, thank you Steve
Alternatively you can use a data attribute:
HTML:
JS:
Not a lot different, but at least you don't need a style block in your template.
is working on a reply...