「CSS3入門」ボタンを作る方法(font-size、border-radius、disabled)

1.font-sizeでボタンのサイズを指定する
サンプルコード
.button1 {font-size: 10px;}
.button2 {font-size: 12px;}
.button3 {font-size: 16px;}
.button4 {font-size: 20px;}
.button5 {font-size: 24px;}

2. border-radiusで角丸ボタンを作る
サンプルコード
.button1 {border-radius: 2px;}
.button2 {border-radius: 4px;}
.button3 {border-radius: 8px;}
.button4 {border-radius: 12px;}
.button5 {border-radius: 50%;}

3.border
サンプルコード
.button1 {
background-color: white;
color: black;
border: 2px solid #4CAF50; /* Green */
}

4.transition-duration で変化に掛かる時間を指定する
サンプルコード
.button {
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
}

.button:hover {
background-color: #4CAF50; /* Green */
color: white;
}
5.box-shadowで影をつける
サンプルコード
.button1 {
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}

.button2:hover {
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);
}

6.disabledでボタンを無効にする
サンプルコード
.disabled {
opacity: 0.6;
cursor: not-allowed;
}

IT

Posted by arkgame