技術頻道導航
HTML/CSS
.NET技術
IIS技術
PHP技術
Js/JQuery
Photoshop
Fireworks
服務器技術
操作系統(tǒng)
網站運營

贊助商

分類目錄

贊助商

最新文章

搜索

純CSS:鼠標移上后,鏈接按鈕顏色顯示漸變效果

作者:admin    時間:2022-8-4 9:12:35    瀏覽:

鼠標移上后,鏈接按鈕顏色顯示漸變效果,這個設計很常見。今天,我介紹一下這個效果的實現方法,是用純CSS來實現的。

完整HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
html, body {
  display: grid;
}
html {
  height: 100%;
}
body {
  place-content: center;
  background: #0e0b12;
}
a {
  padding: 0.875em 2em;
  border-radius: 1.5em;
  background: linear-gradient(90deg, #b828d1, transparent) #0085ff;
  color: #fff;
  font: 600 1.25em/1.25 ubuntu, sans-serif;
  text-decoration: none;
  text-shadow: 1px 1px #000a;
  transition: background-color 0.65s;
}
a:hover, a:focus {
  background-color: #46ffd7;
}
</style>
</head>
<body>
  <a href='#'>這是一個鏈接,鼠標移上來。</a>
</body>
</html>

demodownload

代碼分析

1、背景顏色

下面CSS語句設置鏈接按鈕的背景顏色。

background: linear-gradient(90deg, #b828d1, transparent) #0085ff;

如果沒有這句,那么鼠標懸停效果會變成這樣。

 

 2、過渡時間

下面這句設置過渡時間,是背景顏色變成漸變的過渡時間:0.65s。

transition: background-color 0.65s;

3、鼠標懸停顏色

下面這句設置鼠標懸停后,按鈕的顏色。

a:hover, a:focus {
  background-color: #46ffd7;
}

我們可以更改這個顏色值(#46ffd7),自定義自己喜歡的顏色。

 

 

 

相關文章

標簽: 按鈕  光亮按鈕  漸變按鈕  button  
x