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 href="https://assets.codepen.io/6329135/reset04.css" rel="stylesheet">
</head>

<body>

  <div class="bgCW">
    <a href="#">
      <span class="move mask">
        <img src="https://assets.codepen.io/6329135/beauty.jpg" alt="">
        <span class="cap">背景が中央から横に出現+テキスト bgCW</span>
      </span>
    </a>
  </div>

</body>
              
            
!

CSS

              
                @charset "utf-8";

/* 背景が中央から横に出現+テキスト */
.bgCW {
  position: relative; /*テキストの基点となる位置を定義*/
}

.bgCW span.mask {
  position: relative; /*背景色の基点となる位置を定義*/
  display: block;
  line-height: 0; /*行の高さを0にする*/
  overflow: hidden; /*拡大してはみ出る要素を隠す*/
}

.bgCW span.mask::before {
  content: "";
  position: absolute;
  z-index: 2;
  /*背景色*/
  background-image: linear-gradient(
    to right,
    #ff8177 0%,
    #ff867a 0%,
    #ff8c7f 21%,
    #f99185 52%,
    #cf556c 78%,
    #b12a5b 100%
  );
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: transform 0.3s cubic-bezier(0.8, 0, 0.2, 1) 0s; /*移り変わる速さを変更したい場合はこの数値を変更*/
  transform: scale(0, 1);
  transform-origin: center;
  opacity: 0.5;
}

.bgCW span.mask:hover::before {
  /*hoverした時の変化*/
  transform: scale(1, 1);
  opacity: 0.5;
}

.bgCW span.cap {
  opacity: 0;
  transition: 0.5s ease-in-out; /*移り変わる速さを変更したい場合はこの数値を変更*/
  position: absolute;
  z-index: 3; /*テキストを前面に出す*/
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff; /*テキストの色を変えたい場合はここを修正*/
  line-height: 1.5; /*行の高さを1.5にする*/
}

.bgCW a:hover span.cap {
  /*hoverした時の変化*/
  opacity: 1;
}

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

a {
  color: #333;
  text-decoration: none;
}

.lead {
  position: absolute;
  color: #fff;
  text-shadow: 2px 2px 5px #000;
  font-size: clamp(12px, 5vw, 2rem);
  text-align: center;
  font-weight: bold;

  top: 50%;
  left: 50%;
  transform: translateY(-50%) translateX(-50%);
  white-space: nowrap;
}

/*画像のレスポンシブ*/

img {
  width: 100%;
  height: auto;
}

/* 画像基本設定 */
.move {
  margin: 50px auto; /*中央揃え*/
  box-shadow: 20px -10px #df859b;
}

              
            
!

JS

              
                
              
            
!
999px

Console