更新時(shí)間:2022-02-17 09:53:17 來源:動(dòng)力節(jié)點(diǎn) 瀏覽1392次
.button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
使用該background-color屬性更改按鈕的背景顏色:
.button1 {background-color: #4CAF50;} /* Green */
.button2 {background-color: #008CBA;} /* Blue */
.button3 {background-color: #f44336;} /* Red */
.button4 {background-color: #e7e7e7; color: black;} /* Gray */
.button5 {background-color: #555555;} /* Black */
使用該font-size屬性更改按鈕的字體大小:
.button1 {font-size: 10px;}
.button2 {font-size: 12px;}
.button3 {font-size: 16px;}
.button4 {font-size: 20px;}
.button5 {font-size: 24px;}
使用該padding屬性更改按鈕的填充:
.button1 {padding: 10px 24px;}
.button2 {padding: 12px 28px;}
.button3 {padding: 14px 40px;}
.button4 {padding: 32px 16px;}
.button5 {padding: 16px;}
使用該border-radius屬性為按鈕添加圓角:
.button1 {border-radius: 2px;}
.button2 {border-radius: 4px;}
.button3 {border-radius: 8px;}
.button4 {border-radius: 12px;}
.button5 {border-radius: 50%;}
使用該border屬性為按鈕添加彩色邊框:
.button1 {
background-color: white;
color: black;
border: 2px solid #4CAF50; /* Green */
}
...
當(dāng)您將鼠標(biāo)移到按鈕上時(shí),使用:hover選擇器更改按鈕的樣式。
提示:使用transition-duration屬性來確定“懸停”效果的速度:
.button {
transition-duration: 0.4s;
}
.button:hover {
background-color: #4CAF50; /* Green */
color: white;
}
...
以上就是關(guān)于“CSS按鈕示例”的介紹,大家如果對此比較感興趣,想了解更多相關(guān)知識(shí),不妨來關(guān)注一下動(dòng)力節(jié)點(diǎn)的Java視頻教程,里面的課程內(nèi)容更加豐富,希望對大家的學(xué)習(xí)能夠有所幫助。
初級 202925
初級 203221
初級 202629
初級 203743