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

              
                <!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>7-1-1 背景が流れる(左から右)</title>
<meta name="description"  content="書籍「動くWebデザインアイディア帳」のサンプルサイトです">

<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!--==============レイアウトを制御する独自のCSSを読み込み===============-->
<link rel="stylesheet" type="text/css" href="https://coco-factory.jp/ugokuweb/wp-content/themes/ugokuweb/data/reset.css">
<!-- <link rel="stylesheet" type="text/css" href="https://coco-factory.jp/ugokuweb/wp-content/themes/ugokuweb/data/7-1-1/css/7-1-1.css"> -->
</head>
<body>
    <a href="#" class="btn hover bgleft"><span>hover時に左から右に背景変更</span></a>
</body>
</html>

              
            
!

CSS

              
                @charset "utf-8";

/*== ボタン共通設定 */
.btn{
    /*アニメーションの起点とするためrelativeを指定*/
  position: relative;
  overflow: hidden;
    /*ボタンの形状*/
	text-decoration: none;
	display: inline-block;
  border: 1px solid tomato;/* ボーダーの色と太さ */
  border-radius: 30px;
  padding: 10px 30px;
  text-align: center;
  outline: none;
  /*アニメーションの指定*/   
  transition: ease .2s;
}

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

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

  /*== 背景が流れる(左から右) */

/* ポイントは、擬似要素で背景色を用意し、初めは表示しないようにtransform:scaleでX軸を0にしておく */

.bgleft:before {
 	content: '';
    /*絶対配置で位置を指定*/
 	position: absolute;
 	top: 0;
 	left: 0;
 	z-index: 2; /* 文字の下に背景がくるように、文字より小さい値に*/
  
    /*色や形状*/
 	background: tomato;/*背景色*/
 	width: 100%;
	height: 100%;
  
    /*アニメーション*/
 	transition: transform .5s cubic-bezier(0.8, 0, 0.2, 1) 0s;
 	transform: scale(0, 1); /* scaleXが0なのでhover前は消えている */
	transform-origin: right top; /* 右に消えていく */
}

/*hoverした際の形状*/
.bgleft:hover:before{
	transform-origin:left top; /* 左からスタートする */
	transform:scale(1, 1); /* scaleXが1になるので全表示される */
}


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

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


p{
    margin: 0 0 10px 0;
}

              
            
!

JS

              
                
              
            
!
999px

Console