Need help adding JS Slider


#1

I’m new to Unbounce and am having difficulty adding a slider for testimonials on my landing page. This is what I have done so far:

  1. Used drag and drop HTML widget and enter following code:
    script
    section class="regular slider"
    div
    img src=“img1.jpg”
    /div
    div
    img src=“img2.jpg”
    /div
    /section
    /script

  2. Added Javascript to the JS tab at bottom of interface:
    script
    (document).on('ready', function() { (".regular").slick({
    dots: true,
    infinite: true,
    slidesToShow: 3,
    slidesToScroll: 3
    });
    });
    /script

  3. Adding CSS in bottom CSS panel:

html, body { margin: 0; padding: 0; } * { box-sizing: border-box; } .slider { width: 50%; margin: 100px auto; } .slick-slide { margin: 0px 20px; } .slick-slide img { width: 100%; } .slick-prev:before, .slick-next:before { color: black; }

ANY help would be greatly appreciated. I’m not sure if my failure is in the code or the placement of where the code lives within the Unbounce Editor.


#2

Hi @bthomas,

The formatting of your question got broken a bit but based on what I was able to piece together:

You are trying to add Slick carousel to your Unbounce page.

A few things that stood out without seeing the live page:

  • You are initializing the script but you actually never load the actual JS
  • The CSS looks a bit short and odd
  • You can’t reference images just by a short URL like “img1.jpg” since they don’t reside in the same folder as your Unbounce page

If you share the actual page, the community here might be able to point you further but generally speaking adjusting scripts to work on an Unbounce page requires a bit of JS/CSS knowledge and experience working with the platform.

Best,
Hristian


#3

Hi @bthomas,

I did a testimonial slider for my landing page few months back. Here’s the css script and the html code. You just need to do some basic customization to match colors, fonts etc with your landing page(s).

CSS:

<style>

.container {
	width:100%;
	margin:5px;
    height: 80%;
}


/* testimonials slider geometry */
.tsl {
	border:none;
	padding:1em;
}
.tsl-list {
	list-style-type:none;
	margin:0;
	padding:0;
	position:relative;
	overflow:hidden;
}
.tsl-item {
	position:relative;
	top:0;
	left:100%;
	margin-left:-100%;
	width:100%;
	float:left;
	animation: tsl-fade-in-out 25s infinite;
	animation-play-state:running;
}

/* lets hide all items from second */
.tsl-item + .tsl-item {
	opacity:0;
}

/* animation */

/* animation shift */
/* negative delay needed to pause works correctly on hover */
.tsl-item:nth-child(2) {
	animation-delay: -20s;
}
.tsl-item:nth-child(3) {
	animation-delay: -15s;
}
.tsl-item:nth-child(4) {
	animation-delay: -10s;
}
.tsl-item:nth-child(5) {
	animation-delay: -5s;
}
/*
we have 5 items.
we want each slide plays ≈5s

each slide will play 1/5 of animation = 20%
1% of animation is for transitions (fading)
*/

@keyframes tsl-fade-in-out {
	0% {
		opacity:0;
		z-index:2;
	}
	1% {
		opacity:1;
		z-index:2;
	}
	20% {
		opacity:1;
	}
	21% {
		opacity:0;
		z-index:1;
	}
	100% {
		opacity:0;
	}
}

/* pause on hover */
.tsl-list:hover .tsl-item {
	animation-play-state:paused;
}

/* testimonials theme */
.tsl-content {
	font: 16px/1.4 Ubuntu;
    color: white;
}
.tsl-content p {
	margin-top:0;
}
.tsl-meta {
	font: 14px/1.4 Ubuntu;
	text-align:right;
    color: white;
}
.tsl-meta p {
	margin-bottom:0;
  }
</style>

HTML:

<div class="container">
	
	<!-- testimonials begin -->
	<div class="tsl">
	  <ul class="tsl-list">
	    <li class="tsl-item">
	      <article class="tsl-content">
					<p align="justify">Testimonial 1</p>
				</article>
	      <aside class="tsl-meta">
					<p>Ronald of Orlando, CA<br>Original review posted on Dec. 31, 2015 </p>
				</aside>
	    </li>
	    <li class="tsl-item">
	      <article class="tsl-content">
					<p align="justify">Testimonial 2</p>
				</article>
	      <aside class="tsl-meta">
					<p>Kim of Bloomington, CA<br>Original review posted on Jan. 25, 2016</p>
				</aside>
	    </li>
	    <li class="tsl-item">
	      <article class="tsl-content">
					<p align="justify">Testimonial 3</p>
				</article>
	      <aside class="tsl-meta">
					<p>Kevin of Phoenix, AZ<br>Original review posted on Feb. 10, 2016</p>
				</aside>
	    </li>
	    <li class="tsl-item">
	      <article class="tsl-content">
					<p align="justify">Testimonial 4</p>
				</article>
	      <aside class="tsl-meta">
					<p>Angela of Fort Worth, TX<br>Original review posted on Feb. 9, 2016</p>
				</aside>
	    </li>
	    <li class="tsl-item">
	      <article class="tsl-content">
					<p align="justify">Testimonial 5</p>
				</article>
	      <aside class="tsl-meta">
            <p>Gabriel of Mesa, AZ<br>
            Original review posted on Feb. 4, 2016</p>
				</aside>
	    </li>
	  </ul>
	</div>
	<!-- testimonials end -->
	
</div>

And, if you want you can design a box around it using from within unbounce.

Let me know if you have any questions.


#4

Nishant_Dewan, Thank you for this. I appreciate you taking the time to help me out here. When I enter the HTML in the Custom HTML Widget, the content appears but when I enter the CSS into the Stylesheets editor, nothing is appearing. Have you had this experience? Do I need to call the CSS from within the HTML editor? The visibility is on.

Again, thanks for your help.


#5

@bthomas,

Make sure you customize the font color as per your landing page background image / color. I used it with white font, maybe that’s the reason its not showing up.

You need to make changes to the following part of the css code:

/* testimonials theme */
.tsl-content {
	font: 16px/1.4 Ubuntu;
color: white;
}
.tsl-content p {
	margin-top:0;
}
.tsl-meta {
	font: 14px/1.4 Ubuntu;
	text-align:right;
color: white;
}
.tsl-meta p {
	margin-bottom:0;
  }