Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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 rotatefront"><span>くるっと回転(手前に)</span><span>回転後(手前に)</span></a>
    <a href="#" class="btn rotateback"><span>くるっと回転(奥に)</span><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-position {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/*== ボタン共通設定 */
.btn {
  /*背景の基点とするためrelativeを指定*/
  position: relative;
  /*ボタンの形状*/
  display: inline-block;
  width: 100%;
  height: 80px;
  line-height: 80px;
  padding: 40px 0;
  margin: 20px 0;
  text-align: center;
  outline: none;
  width: clamp(240px, 50vw, 500px); /*ボタンの横幅を全て統一*/
}

/*ボタン内側の設定*/
.btn span {
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  /* 重なりを3Dで表示 */
  transform-style: preserve-3d;
  /* アニメーションの設定 数字が少なくなるほど早く回転 */
  transition: 0.5s;

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

/*== くるっと回転(手前に) */

/* 回転前 */
.rotatefront span:nth-child(1) {
  background-color: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(6.5px);
  -webkit-backdrop-filter: blur(6.5px);
  color: #000;
  transform: rotateX(0deg); /*はじめは回転なし*/
  transform-origin: 0 50% -40px; /* 回転する起点 */
}

/*hoverをした後の形状*/
.rotatefront:hover span:nth-child(1) {
  transform: rotateX(-90deg); /* X軸に-90度回転:手前に回転 */
}

/* 回転後 */
.rotatefront span:nth-child(2) {
  background: rgba(90, 150, 255, 0.5);
  color: #fff;
  transform: rotateX(90deg); /*はじめはX軸に90度回転した状態*/
  transform-origin: 0 50% -40px; /* 回転する起点 */
}

/*hoverをした後の形状*/
.rotatefront:hover span:nth-child(2) {
  transform: rotateX(0deg); /* X軸に0度回転:奥に回転 */
}

/*== くるっと回転(奥に) */

/* 回転前 */
.rotateback span:nth-child(1) {
  background-color: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(6.5px);
  -webkit-backdrop-filter: blur(6.5px);
  color: #000;
  transform: rotateX(0deg); /*はじめは回転なし*/
  transform-origin: 0 50% -40px; /* 回転する起点 */
}

/*hoverをした後の形状*/
.rotateback:hover span:nth-child(1) {
  transform: rotateX(90deg); /* X軸に90度回転:奥に回転 */
}

/* 回転後 */
.rotateback span:nth-child(2) {
  background: rgba(90, 150, 255, 0.5);
  color: #fff;
  transform: rotateX(-90deg); /*はじめはX軸に-90度回転*/
  transform-origin: 0 50% -40px; /* 回転する起点 */
}

/*hoverをした後の形状*/
.rotateback:hover span:nth-child(2) {
  transform: rotateX(0deg); /* X軸に0度回転:手前に回転 */
}

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

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

p {
  margin: 0 0 10px 0;
}

              
            
!

JS

              
                
              
            
!
999px

Console