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="btnarrow">矢印が右に移動して背景がつく</a>
  </div>
</body>
              
            
!

CSS

              
                @charset "utf-8";

/*矢印が右に移動して背景がつく*/
.btnarrow {
  /*矢印の基点とするためrelativeを指定*/
  position: relative;
  /*ボタンの形状*/
  border: 1px solid #555;
  padding: 8px 30px;
  margin: 20px 0;
  display: inline-block;
  text-align: center;
  text-decoration: none;
  color: #333;
  outline: none;

  font-size: max(14px, 2vw);
  white-space: nowrap;
  width: max(255px, 40vw);

  /*アニメーションの指定*/
  transition: all 0.2s linear;
}

.btnarrow:hover {
  background: #333;
  color: #fff;
}

/*矢印と下線の形状*/
.btnarrow::before {
  content: "";
  /*絶対配置で下線の位置を決める*/
  position: absolute;
  top: 50%;
  right: -26px;
  /*下線の形状*/
  width: 40px;
  height: 1px;
  background: #333;
  /*アニメーションの指定*/
  transition: all 0.2s linear;
}

.btnarrow::after {
  content: "";
  /*絶対配置で矢印の位置を決める*/
  position: absolute;
  top: clamp(20%, 1.2vw, 35%);
  right: -20px;
  /*矢印の形状*/
  width: 1px;
  height: 12px;
  background: #333;
  transform: skewX(45deg);
  /*アニメーションの指定*/
  transition: all 0.2s linear;
}

/*hoverした際の移動*/
.btnarrow:hover::before {
  right: -35px;
}

.btnarrow:hover::after {
  right: -30px;
}

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

body {
  width: 100%;
  height: 100vh;
  vertical-align: middle;
  padding: 30px 0;
  text-align: center;

  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;

  background-image: linear-gradient(
    103.3deg,
    rgba(252, 225, 208, 1) 30%,
    rgba(255, 173, 214, 1) 55.7%,
    rgba(162, 186, 245, 1) 81.8%
  );
}

/*ボタンの配置*/
.btn-position {
  display: flex;
  justify-content: center;
}

p {
  margin: 0 0 10px 0;
}

              
            
!

JS

              
                
              
            
!
999px

Console