Hello, I would like to ask your help about why my javaScript doesn't work with my htlm.
Currently, I'm doing the "Testimonial section" and I use "owl carousel", so when the mouse hovers over the picture, it can move forward with the mouse. But I don't know why here it doens't work (I attached the pic of the sample and the one is my work, so you can imagine)
Here the codes I typed
In HTML
Here is the CSS
Here is the JS
Currently, I'm doing the "Testimonial section" and I use "owl carousel", so when the mouse hovers over the picture, it can move forward with the mouse. But I don't know why here it doens't work (I attached the pic of the sample and the one is my work, so you can imagine)
Here the codes I typed
In HTML
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Euphoria</title>
<!--css file-->
<link rel="stylesheet" href="css/stylesheet.css">
<!--bootstrap 5-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.1/css/bootstrap.min.css">
<!--icon cdn-->
<!--font awesome-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css">
<!--bootstrap icon-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
<!--google fonts-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,opsz,wght@0,6..12,200..1000;1,6..12,200..1000&display=swap" rel="stylesheet">
</head>
<body>
<!--Testimonial section-->
<div class="container-xxl py-5">
<div class="container">
<div class="text-center">
<h5 class="section-title bg-white text-center text-dark px-3">Testimonial</h5>
<h3 class="nb-5">Our Clients Say</h3>
</div>
<div class="owl-carousel testimonial-carousel position-relative">
<div class="testimonial-item bg-white text-center border p-4">
<img src="./image/potrait 1.jpg" alt="" class="bg-white rounded-circle shadow p-1 mx-auto mb-3" style="width: 100px; height: 100px;">
<h5 class="mb-0">Chritina</h5>
<p>Dallas, USA</p>
<p class="mb-0">I got good experience with the company. Probally will re-book tours with the company if I come back to Vietnam</p>
</div>
</div>
<div class="owl-carousel testimonial-carousel position-relative">
<div class="testimonial-item bg-white text-center border p-4">
<img src="./image/potrait 8.jpg" alt="" class="bg-white rounded-circle shadow p-1 mx-auto mb-3" style="width: 100px; height: 100px;">
<h5 class="mb-0">Quân</h5>
<p>Quy Nhơn, VN</p>
<p class="mb-0">The staff are friendly, good tour with good price</p>
</div>
</div>
<div class="owl-carousel testimonial-carousel position-relative">
<div class="testimonial-item bg-white text-center border p-4">
<img src="./image/potrait 7.jpg" alt="" class="bg-white rounded-circle shadow p-1 mx-auto mb-3" style="width: 100px; height: 100px;">
<h5 class="mb-0">Trang</h5>
<p>HCM city, VN</p>
<p class="mb-0">I have great momnet with the tour I chose and met new friends</p>
</div>
</div>
<div class="owl-carousel testimonial-carousel position-relative">
<div class="testimonial-item bg-white text-center border p-4">
<img src="./image/potrait 4.jpg" alt="" class="bg-white rounded-circle shadow p-1 mx-auto mb-3" style="width: 100px; height: 100px;">
<h5 class="mb-0">Philip J</h5>
<p>Spain</p>
<p class="mb-0">They care about us, and I love to come bakc to Vietnam</p>
</div>
</div>
<div class="owl-carousel testimonial-carousel position-relative">
<div class="testimonial-item bg-white text-center border p-4">
<img src="./image/potrait 2.jpg" alt="" class="bg-white rounded-circle shadow p-1 mx-auto mb-3" style="width: 100px; height: 100px;">
<h5 class="mb-0">Chritina</h5>
<p>Dallas, USA</p>
<p class="mb-0">We didn't catch the good weather, but the foods there are tasty</p>
</div>
</div>
</div>
</div>
<!--JavaScript Libraries-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
<!--jquery-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<!--bootstrap js link-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<!--js file-->
<script src="./js/main.js"></script>
</body>
</html>
Here is the CSS
CSS:
/*===== testimonial-carousel =====*/
.testimonial-carousel::before{
position: absolute;
content: "";
top: 0;
left: 0;
height: 100%;
width: 0;
background: linear-gradient(to right, rgba(255, 255, 255, 1)0%, rgba(255, 255, 255, 0)100%);
z-index: 1;
}
.testimonial-carousel::after{
position: absolute;
content: "";
top: 0;
right: 0;
height: 100%;
width: 0;
background: linear-gradient(to left, rgba(255, 255, 255, 1)0% rgba(255, 255, 255, 0)100%);
z-index: 1;
}
@media (min-width: 768px){
.testimonial-carousel::before,
.testimonial-carousel::after{
width: 200px;
}
}
.testimonial-carousel .owl-item .testimonial-item,
.testimonial-carousel .owl-item .testimonial-item{
transition: 0.5s;
}
.testimonial-carousel .owl-item.center .testimonial-item{
background: var(--primary) !important;
border-color: var(--primary) !important;
}
.testimonial-carousel .owl-item.center .testimonial-item *{
color: #ffffff !important;
}
.testimonial-carousel .owl-dots {
margin-top: 24px;
display: flex;
align-items: flex-end;
justify-content: center;
}
.testimonial-carousel .owl-dot{
position: relative;
display: inline-block;
margin: 0 5px;
width: 15px;
height: 15px;
border: 1px solid #cccccc;
border-radius: 15px;
transition: 0.5s;
}
.testimonial-carousel .owl-dot.active{
background: var(--primary);
border-color: var(--primary);
}
Here is the JS
JavaScript:
(function ($) {
"use strict"
// testimonial-carousel // need to see why it doesn't work
$(".testimonial-carousel").owlCarousel({
autoplay: true,
smartSpeed: 1000,
center: true,
margin: 24,
dots: true,
loop: true,
nav: false,
responsive: {
0:{
items: 1
},
768:{
items:2
}
}
});
})(jQuery);