sp carousel

In this example below you will see how to do a sp carousel with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by JunkiSuzuki, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright JunkiSuzuki ©

Technologies

  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>sp carousel</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <div class="page_contents">
  <div class="recommend_slider_wrapper">
    <div class="recommend_slider_flipsnap">
      <div class="recommend_product">
        <a href="#"><img src="http://pq.qvc.jp/_c_8/634731.jpg" alt=""></a>
      </div><!-- /.product -->
      <div class="recommend_product">
        <a href="#"><img src="http://pq.qvc.jp/_c_8/634731.jpg" alt=""></a>
      </div><!-- /.product -->
      <div class="recommend_product">
        <a href="#"><img src="http://pq.qvc.jp/_c_8/634731.jpg" alt=""></a>
      </div><!-- /.product -->
      <div class="recommend_product">
	    <a href="#"><img src="http://pq.qvc.jp/_c_8/634731.jpg" alt=""></a>
      </div><!-- /.product -->
      <div class="recommend_product">
        <a href="#"><img src="http://pq.qvc.jp/_c_8/634731.jpg" alt=""></a>
      </div><!-- /.product -->
      <div class="recommend_product">
        <a href="#"><img src="http://pq.qvc.jp/_c_8/634731.jpg" alt=""></a>
      </div><!-- /.product -->
    </div><!-- /.slider -->
  </div><!-- /.slider-wrapper -->
</div>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/JunkiSuzuki/spandx3000carousel-JNXeGW */
/*
html5doctor.com Reset Stylesheet
v1.4
2009-07-27
Author: Richard Clark - http://richclarkdesign.com
*/

html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, dialog, figure, footer, header,
hgroup, menu, nav, section,
time, mark, audio, video {
	margin:0;
	padding:0;
	border:0;
	outline:0;
	font-size:100%;
	vertical-align:baseline;
	background:transparent;
}

body {
	line-height:1;
}

article, aside, dialog, figure, footer, header,
hgroup, nav, section {
	display:block;
}

nav ul {
	list-style:none;
}

blockquote, q {
	quotes:none;
}

blockquote:before, blockquote:after,
q:before, q:after {
	content:'';
	content:none;
}

a {
	margin:0;
	padding:0;
	border:0;
	font-size:100%;
	vertical-align:baseline;
	background:transparent;
}

ins {
	background-color:#ff9;
	color:#000;
	text-decoration:none;
}

mark {
	background-color:#ff9;
	color:#000;
	font-style:italic;
	font-weight:bold;
}

del {
	text-decoration: line-through;
}

abbr[title], dfn[title] {
	border-bottom:1px dotted #000;
	cursor:help;
}

table {
	border-collapse:collapse;
	border-spacing:0;
}

hr {
    display: block;
    height: 1px;
    border: 0;
    border-top: 1px solid #cccccc;
    margin: 1em 0;
    padding: 0;
}

input, select {
	vertical-align: middle;
}

body {
  -webkit-text-size-adjust: 100%;
}

button {
  background-color: transparent;
  border: none;
  cursor: pointer;
  outline: none;
  padding: 0;
  appearance: none;
}

.page_contents {
  width: 1200px;
  max-width: 100%;
  display: block;
  box-sizing: border-box;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  -ms-box-sizing: border-box;
}

.recommend_slider_wrapper {
  width:  80%;
  height: 110px;
  margin : 0 auto;
}

.recommend_slider_flipsnap {
  display: flex;
  justify-content: center;
  margin: 0 auto;
  width: 100%;
  min-width: 640px;
  height: 100px;
  padding: 5px 0 5px 0;
  background: #CCC;
  -webkit-overflow-scrolling: touch;
} 

.recommend_slider_wrapper::-webkit-scrollbar {
  display: none;
}

.recommend_product {
  width: 100px;
  height: 100px;
  margin: 0 3px 0 3px;
  background: #EFEFEF;
}


/*Downloaded from https://www.codeseek.co/JunkiSuzuki/spandx3000carousel-JNXeGW */
// $(function(){
//   $(window).on('load resize',function(){
//     var windowWidth = $(window).width();
//     if (windowWidth <= 800) {
//       var productCount = $(".product").length;
//       var productWidth = $(".product").width(); 

//       console.log(productCount);
//       console.log(productWidth);
//       $(".slider_flipsnap").width( Math.floor(productCount * productWidth));
//       $(".slider_flipsnap").height(Math.floor(productWidth));   
//     }
// 	});
// });

Comments