สร้างหน้า 404 แบบสุ่มพื้นหลัง



<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>404</title>
  <style>
    html,
    body {
      height: 100%;
    }

    body {
      height: 100%;
      width: 100%;
      background-color: #111111;
      font-family: -apple-system, BlinkMacSystemFont, "San Francisco", "Helvetica Neue", Helvetica, Ubuntu, Roboto, Noto, "Segoe UI", Arial, sans-serif;
      color: #ffffff;
      text-align: center;
      margin: 0;
      background-size: cover;
      background-position: center center;
    }

    .background-overlay {
      width: 100%;
      height: 100%;

      position: fixed;
      z-index: 8;
      background: transparent;
      background: -webkit-linear-gradient(top, rgba(0,0,0,0.80) 0%, rgba(0,0,0,0.50) 40%, rgba(0,0,0,0.50) 70%, rgba(0,0,0,0.80) 100%);
      background: linear-gradient(to bottom, rgba(0,0,0,0.80) 0%, rgba(0,0,0,0.50) 40%, rgba(0,0,0,0.50) 70%, rgba(0,0,0,0.80) 100%);
    }

    .content {
      position: relative;
      z-index: 10;
      height: 100%;
      width: 100%;
    }

    h1 {
      font-size: 80px;
      margin: 0;
      font-weight: 800;
      line-height: 1;
      letter-spacing: 0.04em;
      text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }

    a,
    a:hover,
    a:visited {
      color: #ffffff;
    }

    a {
      opacity: 0.6;
      -webkit-transition: all 0.3s ease-in-out;
      transition: all 0.3s ease-in-out;
    }
    a:hover,
    a:focus,
    a:active {
      opacity: 1;
    }

    .error-message {
      margin-top: 12px;
      margin-bottom: 36px;
    }

    .error-message__main {
      font-size: 18px;
      margin: 12px auto;
      line-height: 1.5em;
      text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }

    .error-message__sub {
      font-size: 15px;
      margin: 12px auto;
      line-height: 1.5em;
      text-shadow: 0 1px 2px rgba(0,0,0,0.1);
      opacity: 0.8;
    }

    .table-wrapper {
      display: table;
      width: 100%;
      height: 100%;
    }

    .container {
      margin: auto;
      max-width: 520px;
    }

    .cell-wrapper {
      display: table-cell;
      vertical-align: middle;
    }
  </style>
</head>
<body>
  <div class="background-overlay"></div>
 
  <div class="content">
    <div class="table-wrapper">
      <div class="cell-wrapper">

        <div class="container">

          <h1>404</h1>

          <div class="error-message">
            <p class="error-message__main">The page you are looking for does not match the URL structure of our source.</p>
          </div> <!-- close .error-message -->
        </div> <!-- close .container -->
      </div> <!-- close .cell-wrapper -->
    </div> <!-- close .table-wrapper -->
  </div> <!-- close .content -->

  <script>
    (function (window, undefined) {

      var c,
        cache,
        state,
        view,
        dispatch,
        defaults;

      c = cache = {};
      state = {};
      view = {};
      dispatch = {};
      defaults = {
        gifs: {
          fail: [
            'https://semicon.github.io/img/img_fail/fail-1.gif',
            'https://semicon.github.io/img/img_fail/fail-2.gif',
            'https://semicon.github.io/img/img_fail/fail-3.gif',
            'https://semicon.github.io/img/img_fail/fail-4.gif',
            'https://semicon.github.io/img/img_fail/fail-5.gif',
            'https://semicon.github.io/img/img_fail/fail-6.gif',
            'https://semicon.github.io/img/img_fail/fail-7.gif',
            'https://semicon.github.io/img/img_fail/fail-8.gif',
            'https://semicon.github.io/img/img_fail/fail-9.gif',
            'https://semicon.github.io/img/img_fail/fail-10.gif',
            'https://semicon.github.io/img/img_fail/fail-11.gif',
            'https://semicon.github.io/img/img_fail/fail-12.gif',
            'https://semicon.github.io/img/img_fail/fail-13.gif',
            'https://semicon.github.io/img/img_fail/fail-14.gif',
            'https://semicon.github.io/img/img_fail/fail-15.gif',
            'https://semicon.github.io/img/img_fail/fail-16.gif',
            'https://semicon.github.io/img/img_fail/fail-17.gif',
            'https://semicon.github.io/img/img_fail/fail-18.gif',
            'https://semicon.github.io/img/img_fail/fail-19.gif',
            'https://semicon.github.io/img/img_fail/fail-20.gif',
            'https://semicon.github.io/img/img_fail/fail-21.gif',
            'https://semicon.github.io/img/img_fail/fail-22.gif',
          ]
        }
      };

      cache.init = function () {
        this.body = document.body;
      };

      state.init = function () {
        this.gifs = defaults.gifs.fail;
      };

      state.getRandomGif = function () {
        return this.gifs[Math.floor(Math.random() * this.gifs.length)];
      };

      view.init = function () {
        c.body.style.backgroundImage = 'url(' + state.getRandomGif() + ')';
      };

      cache.init();
      state.init();
      view.init();

    })(window);
  </script>

</body>
</html>


หากเห็นว่ามีประโยชน์โปรดร่วมสนับสนุนเพื่อเป็นกำลังใจในการพัฒนาต่อไป



แสดงความคิดเห็น (0)
ใหม่กว่า เก่ากว่า