mercredi 24 octobre 2018

Javascript overriding CSS

I am creating a simple site in Laravel 5.7. It has a jquery based slider, displaying pictures. I would like to display pictures in the slides background, based on model data passed from controler.

@foreach($slider_projects as $slider_project)
<div class="slide slide-">
    <div class="slide__bg" style="background-image:url()"></div>
    <div class="slide__content">
    </div>
</div>

@endforeach

But my problem is, that the style attribute of my div is being overriden by js code responsible for displaying the slider properly:

$slideBGs = $(".slide__bg"),
$slideBGs.css("transform", "translate3d("+ curSlide*50 +"%,0,0)");

background-image property is not appearing anymore in style__bg divs.

What would be the best approach to render the slider content (background images) dynamically, without disturbing its behaviour (js part)?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire