Ditutorial kali writecode akan membahas slideshow paralax effect responsive dengan bootstrap css3, bagi anda seorang frontend website pasti anda akan sering membuat slider2 di setiap pembuatan tampilan website anda biar lebih menarik dan elegan, sebelum membuat slider ada beberapa library yang harus anda siapkan silakan anda download library slidernya hmodernizr.custom.04022.js bila sudah selesai di download silakan buat folder js didalam folder latihan anda,
susun directory :
- css(demo.css,normalize.css,style.css)
- image
- js
File script css ada tige file css untuk demo.css silakan dicopy dibawah ini letakan didalam folder css latihan anda:
@import url('normalize.css');//load normalize css dalam folder css /* General Demo Style */ body{ font-family: 'Open Sans Condensed','Arial Narrow', serif; background: #ddd url(../images/bg.jpg) repeat top left; font-weight: 400; font-size: 15px; color: #333; } a{ color: #555; text-decoration: none; } .container{ width: 100%; position: relative; } .clr{ clear: both; padding: 0; height: 0; margin: 0; } .container > header{ margin: 10px; padding: 20px 10px 10px 10px; position: relative; display: block; text-shadow: 1px 1px 1px rgba(0,0,0,0.2); text-align: center; } .container > header h1{ font-size: 40px; line-height: 40px; margin: 0; position: relative; font-weight: 300; color: #707a8d; text-shadow: 1px 1px 1px rgba(255,255,255,0.7); } .container > header h1 span{ font-weight: 700; } .container > header h2{ font-size: 14px; font-weight: 300; margin: 0; padding: 15px 0 5px 0; color: #4d525d; font-family: Cambria, Georgia, serif; font-style: italic; text-shadow: 1px 1px 1px rgba(255,255,255,0.9); } /* Header Style */ .codrops-top{ line-height: 24px; font-size: 11px; background: #fff; background: rgba(255, 255, 255, 0.6); text-transform: uppercase; z-index: 9999; position: relative; font-family: Cambria, Georgia, serif; box-shadow: 1px 0px 2px rgba(0,0,0,0.2); } .codrops-top a{ padding: 0px 10px; letter-spacing: 1px; color: #333; display: inline-block; } .codrops-top a:hover{ background: rgba(255,255,255,0.3); } .codrops-top span.right{ float: right; } .codrops-top span.right a{ float: left; display: block; } /* Demo Buttons Style */ .codrops-demos{ text-align:center; display: block; line-height: 30px; padding: 5px 0px; } .codrops-demos a{ display: inline-block; margin: 0px 4px; padding: 0px 6px; color: #aaa; line-height: 20px; font-size: 13px; text-shadow: 1px 1px 1px #fff; border: 1px solid #fff; background: #f6f6f6; /* Old browsers */ background: -moz-linear-gradient(top, #ffffff 0%, #f6f6f6 47%, #ededed 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(47%,#f6f6f6), color-stop(100%,#ededed)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #ffffff 0%,#f6f6f6 47%,#ededed 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #ffffff 0%,#f6f6f6 47%,#ededed 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, #ffffff 0%,#f6f6f6 47%,#ededed 100%); /* IE10+ */ background: linear-gradient(top, #ffffff 0%,#f6f6f6 47%,#ededed 100%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ededed',GradientType=0 ); /* IE6-9 */ box-shadow: 0px 1px 1px rgba(0,0,0,0.3); } .codrops-demos a:hover{ color: #333; } .codrops-demos a:active{ background: #fff; } .codrops-demos a.current-demo, .codrops-demos a.current-demo:hover{ background: #fff; filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ffffff',GradientType=0 ); /* IE6-9 */ } .note{ padding: 20px; text-align: center; }
/*! normalize.css 2012-03-11T12:53 UTC - http://github.com/necolas/normalize.css */ /* ============================================================================= HTML5 display definitions ========================================================================== */ /* * Corrects block display not defined in IE6/7/8/9 & FF3 */ article, aside, details, figcaption, figure, footer, header, hgroup, nav, section, summary { display: block; } /* * Corrects inline-block display not defined in IE6/7/8/9 & FF3 */ audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; } /* * Prevents modern browsers from displaying 'audio' without controls * Remove excess height in iOS5 devices */ audio:not([controls]) { display: none; height: 0; } /* * Addresses styling for 'hidden' attribute not present in IE7/8/9, FF3, S4 * Known issue: no IE6 support */ [hidden] { display: none; } /* ============================================================================= Base ========================================================================== */ /* * 1. Corrects text resizing oddly in IE6/7 when body font-size is set using em units * http://clagnut.com/blog/348/#c790 * 2. Prevents iOS text size adjust after orientation change, without disabling user zoom * www.456bereastreet.com/archive/201012/controlling_text_size_in_safari_for_ios_without_disabling_user_zoom/ */ html { font-size: 100%; /* 1 */ -webkit-text-size-adjust: 100%; /* 2 */ -ms-text-size-adjust: 100%; /* 2 */ } /* * Addresses font-family inconsistency between 'textarea' and other form elements. */ html, button, input, select, textarea { font-family: sans-serif; } /* * Addresses margins handled incorrectly in IE6/7 */ body { margin: 0; } /* ============================================================================= Links ========================================================================== */ /* * Addresses outline displayed oddly in Chrome */ a:focus { outline: thin dotted; } /* * Improves readability when focused and also mouse hovered in all browsers * people.opera.com/patrickl/experiments/keyboard/test */ a:hover, a:active { outline: 0; } /* ============================================================================= Typography ========================================================================== */ /* * Addresses font sizes and margins set differently in IE6/7 * Addresses font sizes within 'section' and 'article' in FF4+, Chrome, S5 */ h1 { font-size: 2em; margin: 0.67em 0; } h2 { font-size: 1.5em; margin: 0.83em 0; } h3 { font-size: 1.17em; margin: 1em 0; } h4 { font-size: 1em; margin: 1.33em 0; } h5 { font-size: 0.83em; margin: 1.67em 0; } h6 { font-size: 0.75em; margin: 2.33em 0; } /* * Addresses styling not present in IE7/8/9, S5, Chrome */ abbr[title] { border-bottom: 1px dotted; } /* * Addresses style set to 'bolder' in FF3+, S4/5, Chrome */ b, strong { font-weight: bold; } blockquote { margin: 1em 40px; } /* * Addresses styling not present in S5, Chrome */ dfn { font-style: italic; } /* * Addresses styling not present in IE6/7/8/9 */ mark { background: #ff0; color: #000; } /* * Addresses margins set differently in IE6/7 */ p, pre { margin: 1em 0; } /* * Corrects font family set oddly in IE6, S4/5, Chrome * en.wikipedia.org/wiki/User:Davidgothberg/Test59 */ pre, code, kbd, samp { font-family: monospace, serif; _font-family: 'courier new', monospace; font-size: 1em; } /* * Improves readability of pre-formatted text in all browsers */ pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; } /* * 1. Addresses CSS quotes not supported in IE6/7 * 2. Addresses quote property not supported in S4 */ /* 1 */ q { quotes: none; } /* 2 */ q:before, q:after { content: ''; content: none; } small { font-size: 75%; } /* * Prevents sub and sup affecting line-height in all browsers * gist.github.com/413930 */ sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } sup { top: -0.5em; } sub { bottom: -0.25em; } /* ============================================================================= Lists ========================================================================== */ /* * Addresses margins set differently in IE6/7 */ dl, menu, ol, ul { margin: 1em 0; } dd { margin: 0 0 0 40px; } /* * Addresses paddings set differently in IE6/7 */ menu, ol, ul { padding: 0 0 0 40px; } /* * Corrects list images handled incorrectly in IE7 */ nav ul, nav ol { list-style: none; list-style-image: none; } /* ============================================================================= Embedded content ========================================================================== */ /* * 1. Removes border when inside 'a' element in IE6/7/8/9, FF3 * 2. Improves image quality when scaled in IE7 * code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/ */ img { border: 0; /* 1 */ -ms-interpolation-mode: bicubic; /* 2 */ } /* * Corrects overflow displayed oddly in IE9 */ svg:not(:root) { overflow: hidden; } /* ============================================================================= Figures ========================================================================== */ /* * Addresses margin not present in IE6/7/8/9, S5, O11 */ figure { margin: 0; } /* ============================================================================= Forms ========================================================================== */ /* * Corrects margin displayed oddly in IE6/7 */ form { margin: 0; } /* * Define consistent border, margin, and padding */ fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: 0.35em 0.625em 0.75em; } /* * 1. Corrects color not being inherited in IE6/7/8/9 * 2. Corrects text not wrapping in FF3 * 3. Corrects alignment displayed oddly in IE6/7 */ legend { border: 0; /* 1 */ padding: 0; white-space: normal; /* 2 */ *margin-left: -7px; /* 3 */ } /* * 1. Corrects font size not being inherited in all browsers * 2. Addresses margins set differently in IE6/7, FF3+, S5, Chrome * 3. Improves appearance and consistency in all browsers */ button, input, select, textarea { font-size: 100%; /* 1 */ margin: 0; /* 2 */ vertical-align: baseline; /* 3 */ *vertical-align: middle; /* 3 */ } /* * Addresses FF3/4 setting line-height on 'input' using !important in the UA stylesheet */ button, input { line-height: normal; /* 1 */ } /* * 1. Improves usability and consistency of cursor style between image-type 'input' and others * 2. Corrects inability to style clickable 'input' types in iOS * 3. Removes inner spacing in IE7 without affecting normal text inputs * Known issue: inner spacing remains in IE6 */ button, input[type="button"], input[type="reset"], input[type="submit"] { cursor: pointer; /* 1 */ -webkit-appearance: button; /* 2 */ *overflow: visible; /* 3 */ } /* * Re-set default cursor for disabled elements */ button[disabled], input[disabled] { cursor: default; } /* * 1. Addresses box sizing set to content-box in IE8/9 * 2. Removes excess padding in IE8/9 * 3. Removes excess padding in IE7 Known issue: excess padding remains in IE6 */ input[type="checkbox"], input[type="radio"] { box-sizing: border-box; /* 1 */ padding: 0; /* 2 */ *height: 13px; /* 3 */ *width: 13px; /* 3 */ } /* * 1. Addresses appearance set to searchfield in S5, Chrome * 2. Addresses box-sizing set to border-box in S5, Chrome (include -moz to future-proof) */ input[type="search"] { -webkit-appearance: textfield; /* 1 */ -moz-box-sizing: content-box; -webkit-box-sizing: content-box; /* 2 */ box-sizing: content-box; } /* * Removes inner padding and search cancel button in S5, Chrome on OS X */ input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; } /* * Removes inner padding and border in FF3+ * www.sitepen.com/blog/2008/05/14/the-devils-in-the-details-fixing-dojos-toolbar-buttons/ */ button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; } /* * 1. Removes default vertical scrollbar in IE6/7/8/9 * 2. Improves readability and alignment in all browsers */ textarea { overflow: auto; /* 1 */ vertical-align: top; /* 2 */ } /* ============================================================================= Tables ========================================================================== */ /* * Remove most spacing between table cells */ table { border-collapse: collapse; border-spacing: 0; }
.sp-slideshow {
position: relative;
margin: 10px auto;
width: 80%;
max-width: 1000px;
min-width: 260px;
height: 460px;
border: 10px solid #fff;
border: 10px solid rgba(255,255,255,0.9);
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.sp-content {
background: #7d7f72 url(../images/grid.png) repeat scroll 0 0;
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
}
.sp-parallax-bg {
background: url(../images/map.png) repeat-x scroll 0 0;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
.sp-slideshow input {
position: absolute;
bottom: 15px;
left: 50%;
width: 9px;
height: 9px;
z-index: 1001;
cursor: pointer;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
}
.sp-slideshow input + label {
position: absolute;
bottom: 15px;
left: 50%;
width: 6px;
height: 6px;
display: block;
z-index: 1000;
border: 3px solid #fff;
border: 3px solid rgba(255,255,255,0.9);
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
-webkit-transition: background-color linear 0.1s;
-moz-transition: background-color linear 0.1s;
-o-transition: background-color linear 0.1s;
-ms-transition: background-color linear 0.1s;
transition: background-color linear 0.1s;
}
.sp-slideshow input:checked + label {
background-color: #fff;
background-color: rgba(255,255,255,0.9);
}
.sp-selector-1, .button-label-1 {
margin-left: -36px;
}
.sp-selector-2, .button-label-2 {
margin-left: -18px;
}
.sp-selector-4, .button-label-4 {
margin-left: 18px;
}
.sp-selector-5, .button-label-5 {
margin-left: 36px;
}
.sp-arrow {
position: absolute;
top: 50%;
width: 28px;
height: 38px;
margin-top: -19px;
display: none;
opacity: 0.8;
cursor: pointer;
z-index: 1000;
background: transparent url(../images/arrows.png) no-repeat;
-webkit-transition: opacity linear 0.3s;
-moz-transition: opacity linear 0.3s;
-o-transition: opacity linear 0.3s;
-ms-transition: opacity linear 0.3s;
transition: opacity linear 0.3s;
}
.sp-arrow:hover{
opacity: 1;
}
.sp-arrow:active{
margin-top: -18px;
}
.sp-selector-1:checked ~ .sp-arrow.sp-a2,
.sp-selector-2:checked ~ .sp-arrow.sp-a3,
.sp-selector-3:checked ~ .sp-arrow.sp-a4,
.sp-selector-4:checked ~ .sp-arrow.sp-a5 {
right: 15px;
display: block;
background-position: top right;
}
.sp-selector-2:checked ~ .sp-arrow.sp-a1,
.sp-selector-3:checked ~ .sp-arrow.sp-a2,
.sp-selector-4:checked ~ .sp-arrow.sp-a3,
.sp-selector-5:checked ~ .sp-arrow.sp-a4 {
left: 15px;
display: block;
background-position: top left;
}
.sp-slideshow input:checked ~ .sp-content {
-webkit-transition: background-position linear 0.6s, background-color linear 0.8s;
-moz-transition: background-position linear 0.6s, background-color linear 0.8s;
-o-transition: background-position linear 0.6s, background-color linear 0.8s;
-ms-transition: background-position linear 0.6s, background-color linear 0.8s;
transition: background-position linear 0.6s, background-color linear 0.8s;
}
.sp-slideshow input:checked ~ .sp-content .sp-parallax-bg {
-webkit-transition: background-position linear 0.7s;
-moz-transition: background-position linear 0.7s;
-o-transition: background-position linear 0.7s;
-ms-transition: background-position linear 0.7s;
transition: background-position linear 0.7s;
}
input.sp-selector-1:checked ~ .sp-content {
background-position: 0 0;
background-color: #727b7f;
}
input.sp-selector-2:checked ~ .sp-content {
background-position: -100px 0;
background-color: #7f7276;
}
input.sp-selector-3:checked ~ .sp-content {
background-position: -200px 0;
background-color: #737f72;
}
input.sp-selector-4:checked ~ .sp-content {
background-position: -300px 0;
background-color: #79727f;
}
input.sp-selector-5:checked ~ .sp-content {
background-position: -400px 0;
background-color: #7d7f72;
}
input.sp-selector-1:checked ~ .sp-content .sp-parallax-bg {
background-position: 0 0;
}
input.sp-selector-2:checked ~ .sp-content .sp-parallax-bg {
background-position: -200px 0;
}
input.sp-selector-3:checked ~ .sp-content .sp-parallax-bg {
background-position: -400px 0;
}
input.sp-selector-4:checked ~ .sp-content .sp-parallax-bg {
background-position: -600px 0;
}
input.sp-selector-5:checked ~ .sp-content .sp-parallax-bg {
background-position: -800px 0;
}
.sp-slider {
position: relative;
left: 0;
width: 500%;
height: 100%;
list-style: none;
margin: 0;
padding: 0;
-webkit-transition: left ease-in 0.8s;
-moz-transition: left ease-in 0.8s;
-o-transition: left ease-in 0.8s;
-ms-transition: left ease-in 0.8s;
transition: left ease-in 0.8s;
}
.sp-slider > li {
color: #fff;
width: 20%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-o-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
height: 100%;
padding: 0 60px;
float: left;
text-align: center;
opacity: 0.4;
-webkit-transition: opacity ease-in 0.4s 0.8s;
-moz-transition: opacity ease-in 0.4s 0.8s;
-o-transition: opacity ease-in 0.4s 0.8s;
-ms-transition: opacity ease-in 0.4s 0.8s;
transition: opacity ease-in 0.4s 0.8s;
}
.sp-slider > li img{
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-o-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
display: block;
margin: 0 auto;
padding: 40px 0 50px 0;
max-height: 100%;
max-width: 100%;
}
input.sp-selector-1:checked ~ .sp-content .sp-slider {
left: 0;
}
input.sp-selector-2:checked ~ .sp-content .sp-slider {
left: -100%;
}
input.sp-selector-3:checked ~ .sp-content .sp-slider {
left: -200%;
}
input.sp-selector-4:checked ~ .sp-content .sp-slider {
left: -300%;
}
input.sp-selector-5:checked ~ .sp-content .sp-slider {
left: -400%;
}
input.sp-selector-1:checked ~ .sp-content .sp-slider > li:first-child,
input.sp-selector-2:checked ~ .sp-content .sp-slider > li:nth-child(2),
input.sp-selector-3:checked ~ .sp-content .sp-slider > li:nth-child(3),
input.sp-selector-4:checked ~ .sp-content .sp-slider > li:nth-child(4),
input.sp-selector-5:checked ~ .sp-content .sp-slider > li:nth-child(5){
opacity: 1;
}
@media screen and (max-width: 840px){
.sp-slideshow { height: 345px; }
}
@media screen and (max-width: 680px){
.sp-slideshow { height: 285px; }
}
@media screen and (max-width: 560px){
.sp-slideshow { height: 235px; }
}
@media screen and (max-width: 320px){
.sp-slideshow { height: 158px; }
}
Buat file index.html script kode :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Paralax efect slideshow responsive css3</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="Codrops" />
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript" src="js/modernizr.custom.04022.js"></script>
<link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700,300,300italic' rel='stylesheet' type='text/css'>
</head>
<body>
<div class="container">
<!-- Codrops top bar -->
<div class="codrops-top">
Slideshow with paralax
<div class="clr"></div>
</div><!--/ Codrops top bar -->
<header>
<h1>Paralax efect slideshow responsive css3</h1>
</header>
<div class="sp-slideshow">
<input id="button-1" type="radio" name="radio-set" class="sp-selector-1" checked="checked" />
<label for="button-1" class="button-label-1"></label>
<input id="button-2" type="radio" name="radio-set" class="sp-selector-2" />
<label for="button-2" class="button-label-2"></label>
<input id="button-3" type="radio" name="radio-set" class="sp-selector-3" />
<label for="button-3" class="button-label-3"></label>
<input id="button-4" type="radio" name="radio-set" class="sp-selector-4" />
<label for="button-4" class="button-label-4"></label>
<input id="button-5" type="radio" name="radio-set" class="sp-selector-5" />
<label for="button-5" class="button-label-5"></label>
<label for="button-1" class="sp-arrow sp-a1"></label>
<label for="button-2" class="sp-arrow sp-a2"></label>
<label for="button-3" class="sp-arrow sp-a3"></label>
<label for="button-4" class="sp-arrow sp-a4"></label>
<label for="button-5" class="sp-arrow sp-a5"></label>
<div class="sp-content">
<div class="sp-parallax-bg"></div>
<ul class="sp-slider clearfix">
<li><img src="images/image1.png" alt="image01" /></li>
<li><img src="images/image2.png" alt="image02" /></li>
<li><img src="images/image3.png" alt="image03" /></li>
<li><img src="images/image4.png" alt="image04" /></li>
<li><img src="images/image5.png" alt="image05" /></li>
</ul>
</div><!-- sp-content -->
</div><!-- sp-slideshow -->
<p class="note">Placeholder text from <a href="http://hipsteripsum.me">http://hipsteripsum.me</a></p>
</div>
</body>
</html>
Slidershow potongan kode index.html dibawah ini yang akan menjadi slidernya
<!-- slider -->
<div class="sp-slideshow">
<input id="button-1" type="radio" name="radio-set" class="sp-selector-1" checked="checked" />
<label for="button-1" class="button-label-1"></label>
<input id="button-2" type="radio" name="radio-set" class="sp-selector-2" />
<label for="button-2" class="button-label-2"></label>
<input id="button-3" type="radio" name="radio-set" class="sp-selector-3" />
<label for="button-3" class="button-label-3"></label>
<input id="button-4" type="radio" name="radio-set" class="sp-selector-4" />
<label for="button-4" class="button-label-4"></label>
<input id="button-5" type="radio" name="radio-set" class="sp-selector-5" />
<label for="button-5" class="button-label-5"></label>
<label for="button-1" class="sp-arrow sp-a1"></label>
<label for="button-2" class="sp-arrow sp-a2"></label>
<label for="button-3" class="sp-arrow sp-a3"></label>
<label for="button-4" class="sp-arrow sp-a4"></label>
<label for="button-5" class="sp-arrow sp-a5"></label>
<div class="sp-content">
<div class="sp-parallax-bg"></div>
<ul class="sp-slider clearfix">
<li><img src="images/image1.png" alt="image01" /></li>
<li><img src="images/image2.png" alt="image02" /></li>
<li><img src="images/image3.png" alt="image03" /></li>
<li><img src="images/image4.png" alt="image04" /></li>
<li><img src="images/image5.png" alt="image05" /></li>
</ul>
</div><!-- sp-content -->
</div><!-- sp-slideshow -->
untuk download backroundnya silakan DISINI, untuk slider lengkapnya silakan downlod di Tympanus
Posting Komentar
Posting Komentar