Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

HTML & CSS Can't make work owl.carousel.js

SpongeBOB

Well-Known Coder
Hi everyone,

I try to make owl.carousel.js working.
I followed the instructions

but instead of having
2021-05-21-0948.png

I got :
2021-05-21-0949.png


here the html:
[CODE lang="html" title="The HTML"]<!doctype html>

<html lang="en">

<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Carousel test</title>


<link rel="stylesheet" href="static/OwlCarousel/owl.carousel.min.css">
<link rel="stylesheet" href="static/OwlCarousel/assets/owl.theme.default.min.css">


</head>

<body bgcolor="#1c1c1c" text="#E1E1E1">


<div class="owl-carousel">
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
</div>


<script src="static/jquery/jquery-3.6.0.min"></script>
<script src="static/OwlCarousel/owl.carousel.min.js"></script>


<script>
$(document).ready(function() {
var owl = $('.owl-carousel');
owl.owlCarousel({
margin: 10,
nav: true,
loop: true,
responsive: {
0: {
items: 1
},
600: {
items: 3
},
1000: {
items: 5
}
}
})
})
</script>

</body>

</html>[/CODE]



[CODE title="The directory structure"].
| test.html
|
\---static
|
+---jquery
| jquery-3.6.0.min.js
|
\---OwlCarousel
| owl.carousel.min.js
|
\---assets
ajax-loader.gif
owl.carousel.css
owl.carousel.min.css
owl.theme.default.css
owl.theme.default.min.css
owl.theme.green.css
owl.theme.green.min.css
owl.video.play.png[/CODE]



Any ideas ?
 
Solution
a second error on my end :/


[CODE lang="html" title="not good to rush" highlight="13"]<!doctype html>

<html lang="en">

<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Carousel test</title>


<link rel="stylesheet" href="static/OwlCarousel/owl.carousel.min.css">
<link rel="stylesheet" href="static/OwlCarousel/assets/owl.theme.default.min.css">


</head>

<body bgcolor="#1c1c1c" text="#E1E1E1">


<div class="owl-carousel">
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
</div>


<script src="static/jquery/jquery-3.6.0.min"></script>
<script...
I've found the error ! (line 33) ->
it was missing .js :x3:

[CODE lang="html" title="the error" highlight="33"]<!doctype html>

<html lang="en">

<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Carousel test</title>


<link rel="stylesheet" href="static/OwlCarousel/owl.carousel.min.css">
<link rel="stylesheet" href="static/OwlCarousel/assets/owl.theme.default.min.css">


</head>

<body bgcolor="#1c1c1c" text="#E1E1E1">


<div class="owl-carousel">
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
</div>


<script src="static/jquery/jquery-3.6.0.min"></script>
<script src="static/OwlCarousel/owl.carousel.min.js"></script>


<script>
$(document).ready(function() {
var owl = $('.owl-carousel');
owl.owlCarousel({
margin: 10,
nav: true,
loop: true,
responsive: {
0: {
items: 1
},
600: {
items: 3
},
1000: {
items: 5
}
}
})
})
</script>

</body>

</html>[/CODE]

but with this fixe I still not have the good output !

I got this now ->

2021-05-21-1020_.png
 
a second error on my end :/


[CODE lang="html" title="not good to rush" highlight="13"]<!doctype html>

<html lang="en">

<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Carousel test</title>


<link rel="stylesheet" href="static/OwlCarousel/owl.carousel.min.css">
<link rel="stylesheet" href="static/OwlCarousel/assets/owl.theme.default.min.css">


</head>

<body bgcolor="#1c1c1c" text="#E1E1E1">


<div class="owl-carousel">
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
</div>


<script src="static/jquery/jquery-3.6.0.min"></script>
<script src="static/OwlCarousel/owl.carousel.min.js"></script>


<script>
$(document).ready(function() {
var owl = $('.owl-carousel');
owl.owlCarousel({
margin: 10,
nav: true,
loop: true,
responsive: {
0: {
items: 1
},
600: {
items: 3
},
1000: {
items: 5
}
}
})
})
</script>

</body>

</html>[/CODE]

line 13 should be
[CODE title="the correction"]<link rel="stylesheet" href="static/OwlCarousel/assets/owl.carousel.min.css">[/CODE]
 
Solution
Hi @SpongeBOB

There are alternatives of owl carousel, yes it is used by many but for beginners its difficult to work with: anyways I have linked a file for owl carousel with all the necessary links and images. It is a working slider of course.

The alternatives: if you are still confused then you should try swiperjs I find its working similar to the owl carousel but customization is far easier than owl and the best part it doesn't requires jQuery: only its CSS and JS and you are good to go definitely try that out. Basic code file is linked.

Learn more about web development and web designing here.
 

Attachments

Last edited by a moderator:

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom