簡體   English   中英

如何在鼠標懸停時平滑插入框陰影效果?

[英]How to smoothly insert box shadow efffect on mouseover?

如何在此網站上創建平滑的文本輸入框陰影效果

使用CSS3:

#element {
/* all your styles.. */
-webkit-transition:0.2s linear;
-moz-transition:0.2s linear;
-o-transition:0.2s linear;
transition:0.2s linear;
}

#element:hover {
-webkit-box-shadow:0 0 5px blue;
-moz-box-shadow:0 0 5px blue;
-o-box-shadow:0 0 5px blue;
box-shadow:0 0 5px blue;
}

嘗試在那里使用Firebug或類似工具。

您聲明一些初始的“不可見”框陰影及其可見副本,並另外聲明一些過渡:

.elem {
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
    transition: box-shadow 0.2s linear 0s;
}
.elem:hover {
    box-shadow: 0 0 8px rgba(82, 168, 236, 0.6);
}

此樣式是從該站點提取的。

編輯:您希望將鼠標懸停而不是集中精力。

.element
{
   background-color: #fff;
   border: 1px solid #ccc;
   -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
   -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
   box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
   -webkit-transition: border linear .2s,box-shadow linear .2s;
   -moz-transition: border linear .2s,box-shadow linear .2s;
   -o-transition: border linear .2s,box-shadow linear .2s;
   transition: border linear .2s,box-shadow linear .2s;
}
.elem:hover 
{
    box-shadow: 0 0 8px rgba(82, 168, 236, 0.6);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM