Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <head>
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <!--==============レイアウトを制御する独自のCSSを読み込み===============-->
  <link rel="stylesheet" type="text/css" href="https://assets.codepen.io/6329135/reset.css">
</head>

<body>
  <div class="btn-position">
    <a href="#" class="btn bgleft"><span>背景が流れる(左から右)</span></a>
    <a href="#" class="btn bgright"><span>背景が流れる(右から左)</span></a>
    <a href="#" class="btn bgtop"><span>背景が流れる(上から下)</span></a>
    <a href="#" class="btn bgbottom"><span>背景が流れる(下から上)</span></a>
    <a href="#" class="btn bgcenterx"><span>背景が流れる(中央から横全体)</span></a>
    <a href="#" class="btn bgcentery"><span>背景が流れる(中央から縦全体)</span></a>
    <a href="#" class="btn bgcenterout"><span>背景が流れる(中央から外)</span></a>
    <a href="#" class="btn bgskew"><span>背景が流れる(斜め)</span></a>
  </div>
</body>
              
            
!

CSS

              
                @charset "utf-8";

/*== 背景共通設定 */
body {
  width: 100%;
  height: 100vh;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  background-image: url("https://assets.codepen.io/6329135/img_06.jpg");
  object-fit: cover;
}

/*== ボタン共通設定 */
.btn {
  /*アニメーションの起点とするためrelativeを指定*/
  position: relative;
  overflow: hidden;
  /*ボタンの形状*/
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: inline-block;
  padding: 20px 0;
  margin: 10px 0;
  text-align: center;
  outline: none;
  transition: ease 0.2s; /*アニメーションの指定*/
  width: clamp(240px, 50vw, 500px); /*ボタンの横幅を全て統一*/

  background-color: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(6.5px);
  -webkit-backdrop-filter: blur(6.5px);

  box-shadow: 0px 6px 15px 0px rgba(142, 142, 142, 0.19);
  -webkit-box-shadow: 0px 6px 15px 0px rgba(142, 142, 142, 0.19);

  border-radius: 12px;
  -webkit-border-radius: 12px;
  color: rgba(255, 255, 255, 0.898);
}

/*ボタンの配置*/
.btn-position {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/*ボタン内spanの形状*/
.btn span {
  position: relative;
  z-index: 3; /*z-indexの数値をあげて文字を背景よりも手前に表示*/
  color: #333;

  font-size: clamp(0.8rem, 2vw, 1rem);
}

.btn:hover span {
  color: #fff;
}

/* ==== 背景が流れる(左から右) ==== */
.bgleft:before {
  content: "";
  /*絶対配置で位置を指定*/
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  /*色や形状*/
  background: rgba(90, 150, 255, 0.5);
  width: 100%;
  height: 100%;
  /*アニメーション*/
  transition: transform 0.6s cubic-bezier(0.8, 0, 0.2, 1) 0s;
  transform: scale(0, 1);
  transform-origin: right top;
}

/*hoverした際の形状*/
.bgleft:hover:before {
  transform-origin: left top;
  transform: scale(1, 1);
}

/* ==== 背景が流れる(右から左) ==== */
.bgright:before {
  content: "";
  /*絶対配置で位置を指定*/
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  /*色や形状*/
  background: rgba(90, 150, 255, 0.5);
  width: 100%;
  height: 100%;
  /*アニメーション*/
  transition: transform 0.6s cubic-bezier(0.8, 0, 0.2, 1) 0s;
  transform: scale(0, 1);
  transform-origin: left top;
}

/*hoverした際の形状*/
.bgright:hover:before {
  transform-origin: right top;
  transform: scale(1, 1);
}

/* ==== 背景が流れる(上から下) ==== */
.bgtop:before {
  content: "";
  /*絶対配置で位置を指定*/
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  /*色や形状*/
  background: rgba(90, 150, 255, 0.5);
  width: 100%;
  height: 0;
  /*アニメーション*/
  transition: 0.3s cubic-bezier(0.8, 0, 0.2, 1) 0s;
}

/*hoverした際の形状*/
.bgtop:hover:before {
  height: 100%;
  background-color: rgba(90, 150, 255, 0.5);*
}

/* ==== 背景が流れる(下から上) ==== */
.bgbottom:before {
  content: "";
  /*絶対配置で位置を指定*/
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 2;
  /*色や形状*/
  background: rgba(90, 150, 255, 0.5);
  width: 100%;
  height: 0;
  /*アニメーション*/
  transition: 0.3s cubic-bezier(0.8, 0, 0.2, 1) 0s;
}

/*hoverした際の形状*/
.bgbottom:hover:before {
  height: 100%;
  background: rgba(90, 150, 255, 0.5);
}
/* ==== 背景が流れる(中央から横全体) ==== */
.bgcenterx:before {
  content: "";
  /*絶対配置で位置を指定*/
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  /*色や形状*/
  background: rgba(90, 150, 255, 0.5);
  width: 100%;
  height: 100%;
  /*アニメーション*/
  transition: transform 0.3s cubic-bezier(0.8, 0, 0.2, 1) 0s;
  transform: scale(0, 1);
  transform-origin: top; /* bottomでも同じです */
}

/*hoverした際の形状*/
.bgcenterx:hover:before {
  transform: scale(1, 1);
}
/* ==== 背景が流れる(中央から縦全体) ==== */
.bgcentery:before {
  content: "";
  /*絶対配置で位置を指定*/
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  /*色や形状*/
  background: rgba(90, 150, 255, 0.5);
  width: 100%;
  height: 100%;
  /*アニメーション*/
  transition: transform 0.3s cubic-bezier(0.8, 0, 0.2, 1) 0s;
  transform: scale(1, 0);
  transform-origin: center;
}

/*hoverした際の形状*/
.bgcentery:hover:before {
  transform: scale(1, 1);
}

/* ==== 背景が流れる(中央から外) ==== */
.bgcenterout:before {
  content: "";
  /*絶対配置で位置を指定*/
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  /*色や形状*/
  background: rgba(90, 150, 255, 0.5);
  width: 100%;
  height: 100%;
  /*アニメーション*/
  transition: transform 0.3s cubic-bezier(0.8, 0, 0.2, 1) 0s;
  transform: scale(0, 0);
  transform-origin: center;
}

/*hoverした際の形状*/
.bgcenterout:hover:before {
  transform: scale(1, 1);
}

/* ==== 背景が流れる(斜め) ==== */
.bgskew::before {
  content: "";
  /*絶対配置で位置を指定*/
  position: absolute;
  top: 0;
  left: -130%;
  /*色や形状*/
  background: rgba(90, 150, 255, 0.5);
  width: 120%;
  height: 100%;
  transform: skewX(-25deg);
}

/*hoverした時のアニメーション*/
.bgskew:hover::before {
  animation: skewanime 0.7s forwards; /*アニメーションの名前と速度を定義*/
}

@keyframes skewanime {
  0% {
    right: -10%; /*画面の見えていない左から右へ移動する終了地点*/
  }
  100% {
    left: 110%; /*画面の見えていない左から右へ移動する終了地点*/
  }
}

/*========= レイアウトのためのCSS ===============*/

body {
  vertical-align: middle;
  padding: 20px 0;
  text-align: center;
}

p {
  margin: 0 0 10px 0;
}

              
            
!

JS

              
                
              
            
!
999px

Console