読者です 読者をやめる 読者になる 読者になる

WEBデザインの勉強

WEB制作初心者が1から勉強するブログ。

色の変換ができるライブラリRGB color parser in JavaScript

f:id:mmmmofu:20170511231213p:plain

公式サイト
RGB color parser in JavaScript / Stoyan's phpied.com

デモ
http://efu.sakura.ne.jp/web/background/

<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <title>CSSの色の値を変換</title>
  <link rel="stylesheet" href="http://efu.sakura.ne.jp/web/common/css/reset.css">
  <link rel="stylesheet" href="css/style.css">
  <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
  <script src="js/rgbcolor.js"></script>
  <script src="js/script.js"></script>
</head>
<body>
  <div class="head">
    <h1>CSSの色の値を変換</h1>
  </div>
  <div class="section section01">
    <p class="css_color"><span>CSSで指定した値</span>#588C7E</p>
    <div class="text text01">
      <p class="text01-01"><span>JSで取得した値</span></p>
      <p class="text01-02"><span>R・G・Bを別々に取得</span></p>
      <p class="text01-03"><span>16進数</span></p>
      <p class="text01-04"><span>rgb</span></p>
    </div>
  </div>
  <div class="section section02">
    <p class="css_color"><span>CSSで指定した値</span>rgb(242, 227, 148)</p>
    <div class="text text02">
      <p class="text02-01"><span>JSで取得した値</span></p>
      <p class="text02-02"><span>R・G・Bを別々に取得</span></p>
      <p class="text02-03"><span>16進数</span></p>
      <p class="text02-04"><span>rgb</span></p>
    </div>
  </div>
  <div class="section section03">
    <p class="css_color"><span>CSSで指定した値</span>rndianred</p>
    <div class="text text03">
      <p class="text03-01"><span>JSで取得した値</span></p>
      <p class="text03-02"><span>R・G・Bを別々に取得</span></p>
      <p class="text03-03"><span>16進数</span></p>
      <p class="text03-04"><span>rgb</span></p>
    </div>
  </div>
</body>
</html>
html,body {
  width: 100%;
  height: 100%;
}

.head {
  display: table;
  width: 100%;
  height: 10%;
  background: #333;
}

h1 {
  display: table-cell;
  color: #FFF;
  text-align: center;
  font-size: 20px;
  font-weight: bold;
  vertical-align: middle;
}

.section {
  float: left;
  width: 33.333%;
  height: 90%;
}

.section01 {
  background-color: #588C7E;
}

.section02 {
  background-color: rgb(242, 227, 148);
}

.section03 {
  background-color: indianred;
}

.css_color {
  margin-top: 50px;
  font-size: 20px;
  font-weight: bold;
  color: #FFF;
  text-align: center;
}

.css_color span {
  display: block;
  padding-bottom: 6px;
  font-weight: normal;
  font-size: 10px;
}

.text {
  margin-top: 50px;
  color: #FFF;
  text-align: center;
}

.text p {
  display: block;
  padding: 0 0 50px;
}

.text p span {
  display: block;
  padding-bottom: 6px;
  font-size: 10px;
}
$(function(){
  var bgColor1 = $('.section01').css('background-color');
  var bgColor2 = $('.section02').css('background-color');
  var bgColor3 = $('.section03').css('background-color');
  $('.text01-01').append(bgColor1);
  $('.text02-01').append(bgColor2);
  $('.text03-01').append(bgColor3);
  var color1 = new RGBColor('#588C7E');
  var color2 = new RGBColor('rgb(242, 227, 148)');
  var color3 = new RGBColor('indianred');
  if (color1.ok) {
    $('.text01-02').append(color1.r + ', ' + color1.g + ', ' + color1.b);
    $('.text01-03').append(color1.toHex());
    $('.text01-04').append(color1.toRGB());
  }
  if (color2.ok) {
    $('.text02-02').append(color2.r + ', ' + color1.g + ', ' + color1.b);
    $('.text02-03').append(color2.toHex());
    $('.text02-04').append(color2.toRGB());
  }
  if (color3.ok) {
    $('.text03-02').append(color3.r + ', ' + color1.g + ', ' + color1.b);
    $('.text03-03').append(color3.toHex());
    $('.text03-04').append(color3.toRGB());
  }
});
広告を非表示にする

HTML5のaudioやvideoの埋め込み・再生ができるjQueryプラグインjPlayer

f:id:mmmmofu:20170510232911p:plain

公式サイト
jplayer.org

デモ
http://efu.sakura.ne.jp/web/jplayer/
※音が流れます

<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <title>jPlayer</title>
  <link rel="stylesheet" href="http://efu.sakura.ne.jp/web/common/css/reset.css">
  <link rel="stylesheet" href="http://efu.sakura.ne.jp/web/common/css/font-awesome.min.css">
  <link rel="stylesheet" href="css/style.css">
  <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
  <script src="js/jquery.jplayer.js"></script>
  <script src="js/script.js"></script>
</head>
<body>
  <div class="sound">
    <div class="sound_icon">
      <i class="fa fa-play-circle play" aria-hidden="true"></i>
      <i class="fa fa-pause-circle pause" aria-hidden="true"></i>
    </div>
  </div>
  <div id="audio"></div>
  <ul class="soundlist">
    <li class="sound1">
      <img src="img/icon01.png" alt="">
      <div class="play1"></div>
      <div class="pause1"></div>
      <div id="audio1"></div>
    </li>
    <li class="sound2">
      <img src="img/icon02.png" alt="">
      <div class="play2"></div>
      <div class="pause2"></div>
      <div id="audio2"></div>
    </li>
  </ul>
</body>
</html>
body {
  text-align: center;
}

.sound {
  position: relative;
  display: inline-block;
  margin: 50px 0;
  cursor: pointer;
}

.sound_icon i {
  font-size: 83px;
  -webkit-transition: all .3s linear;
  -o-transition: all .3s linear;
  transition: all .3s linear;
}

.fa-pause-circle {
  display: none;
  color: #D0DD97;
}

.fa-pause-circle:hover {
  color: #658361;
}

.fa-play-circle {
  color: #F49393;
}

.fa-play-circle:hover {
  color: #F21368;
}

.soundlist {
  font-size: 0;
  text-align: center;
}

.soundlist li {
  position: relative;
  display: inline-block;
  margin-left: 50px;
  cursor: pointer;
}

.soundlist li:first-child {
  margin-left: 0;
}

.soundlist li .play1, .soundlist li .play2, .soundlist li .pause1, .soundlist li .pause2 {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
$(function(){
  $('.sound').on('click', function(){
    $('#audio').jPlayer({
      ready: function () {
        $(this).jPlayer("setMedia", {
          mp3: "mp3/sound.mp3"
        }).jPlayer('play');
      },
      loop: false,
      volume: 0.5,
      ssupplied: 'mp3',
      cssSelectorAncestor: '.sound',
      cssSelector: {play: '.play',pause: '.pause'},
      play: function(){
        console.log('play');
      },
      pause: function(){
        console.log('pause');
      },
      ended: function(){
        console.log('ended');
      }
    });
  });

  $('.soundlist li').on('mouseenter', function(){
    var current = $(this).index() + 1;
    $('#audio' + current).jPlayer({
      ready: function () {
        $(this).jPlayer("setMedia", {
          mp3: "mp3/sound" + current + ".mp3"
        }).jPlayer('play');
      },
      loop: false,
      volume: 0.5,
      ssupplied: 'mp3',
      cssSelectorAncestor: '.sound',
      cssSelector: {play: '.play' + current, pause: '.pause' + current}
    });
  }).on('mouseleave', function(){
    var current = $(this).index() + 1;
    $('#audio' + current).jPlayer("destroy");
  });
});

素材お借りしました。
www.hmix.net

広告を非表示にする

jQuery UI Datepicker

f:id:mmmmofu:20170507151810p:plain

jqueryui.com

jqueryui.com

github.com

デモ
http://efu.sakura.ne.jp/web/datepicker/

<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <title>jQuery UI Datepicker</title>
  <link rel="stylesheet" href="http://efu.sakura.ne.jp/web/common/css/reset.css">
  <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.19/themes/swanky-purse/jquery-ui.css">
  <link rel="stylesheet" href="style.css">
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.19/jquery-ui.min.js"></script>
  <script src="datepicker-ja.js"></script>
  <script src="script.js"></script>
</head>
<body>
  <h1>Datepicker</h1>
  <p class="datepicker"><input type="text" id="datepicker"></p>
</body>
</html>
h1 {
  text-align: center;
  font-size: 28px;
  padding: 15px 0;
}
.datepicker {
  width: 100px;
  margin: 0 auto;
}

.datepicker input {
  width: 100px;
  padding: 10px 5px;
  font-size: 18px;
}

*:focus {
  outline: none;
}
$(function(){
  $("#datepicker").datepicker();
});
広告を非表示にする