webサイト制作の勉強|2017月7月クラスブログ

webサイト制作の勉強に関する解説ブログです。

bxslider.jsを使用したサムネイル・スライドギャラリー

f:id:yachin29:20171016212341p:plain




HTMLソース

<!doctype html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>bxslider.jsを使用したサムネイル・スライドギャラリーの作例</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/jquery.bxslider.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="js/jquery.bxslider.js"></script>
<script>
$(function(){
$('.bxslider').bxSlider({
  pagerCustom: '#bx-pager'
});
});
</script>
</head>

<body>

<div class="gallery">
<h1>bxslider.jsを使用した<br>サムネイル・スライドギャラリーの作例</h1>
<ul class="bxslider">
  <li><img src="img/01.jpg" alt=""></li>
  <li><img src="img/02.jpg" alt=""></li>
  <li><img src="img/03.jpg" alt=""></li>
  <li><img src="img/04.jpg" alt=""></li>
</ul>

<div id="bx-pager" class="thumb">
<ul>
<li><a data-slide-index="0" href=""><img src="img/01s.jpg" /></a></li>
<li><a data-slide-index="1" href=""><img src="img/02s.jpg" /></a></li>
<li><a data-slide-index="2" href=""><img src="img/03s.jpg" /></a></li>
<li><a data-slide-index="3" href=""><img src="img/04s.jpg" /></a></li>
<ul>
</div>

</body>
</html>


CSS

@charset "UTF-8";
/* CSS Document */

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, canvas, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section, summary,
time, mark, audio, video {
    margin:0;
    padding:0;
    border:0;
    outline:0;
    font-size:100%;
    vertical-align:baseline;
    background:transparent;
    color: #505050;
    box-sizing:border-box;
    font-feature-settings : "palt";
}

body {
    line-height:1;
    overflow-x: hidden;
    font-family: 'Open Sans', "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "メイリオ", Meiryo,"sans-serif";
}

article,aside,details,figcaption,figure,
footer,header,hgroup,menu,nav,section { 
    display:block;
}

nav ul,ul {
    list-style:none;
}

blockquote, q {
    quotes:none;
}

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

a {
    margin:0;
    padding:0;
    font-size:100%;
    vertical-align:baseline;
    background:transparent;
    text-decoration: none;
    color: #222;
}

/* change colours to suit your needs */
ins {
    background-color:#ff9;
    color:#000;
    text-decoration:none;
}

/* change colours to suit your needs */
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;
    cursor:help;
}

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

/* change border colour to suit your needs */
hr {
    display:block;
    height:1px;
    border:0;   
    border-top:1px solid #cccccc;
    margin:1em 0;
    padding:0;
}

input, select {
    vertical-align:middle;
}
img {
border: none;
vertical-align: bottom;
}


/*ギャラリー*/
.gallery {
  max-width:968px;
  margin: 0 auto;
  overflow: hidden;
}
.gallery h1 {
font-size: 26px;
text-align: center;
font-weight: normal;
margin:20px 0;
line-height: 1.4;
}
.gallery img {
max-width: 100%;
}
.bxslider {
padding: 4px;
}
.thumb {
max-width: 968px;
}
.thumb li {
width:calc((100% - 32px) / 4 );
float: left;
margin:4px;
}
.thumb img:hover {
opacity: 0.7;
}
.thumb a.active img {
  display:block;
  border-bottom:4px solid #333;
  padding-bottom:5px;
  box-sizing:border-box;
}
br {
  display:none;
}
@media screen and (max-width:640px) {
  br {
    display:block;
  }
}




bxslider.com