可以使用 css3 轉換輪廓顏色 (possible to transition outline color with css3)


問題描述

可以使用 css3 轉換輪廓顏色 (possible to transition outline color with css3)

Is it not possible to transition outlines with css3?

body{margin:10px;padding:0px;}
#tDiv{
    background‑color:#999;
    width:500px; 
    height:500px;
    color:black;
   outline: 5px dashed #222; 
    ‑moz‑transition: color 2s;
    ‑o‑transition: color 2s;
    ‑webkit‑transition: color 2s;
    transition: color 2s;
    ‑moz‑transition: outline‑color .7s ease‑out;
    ‑o‑transition: outline‑color .7s ease‑out;
    ‑webkit‑transition: outline‑color .7s ease‑out;
    transition: outline‑color .7s ease‑out;
    ‑moz‑transition: background‑color .7s ease‑out;
    ‑o‑transition: background‑color .7s ease‑out;
    ‑webkit‑transition: background‑color .7s ease‑out;
    transition: outline‑background .7s ease‑out;   
}
#tDiv:hover{
    color:green;
    background‑color:gold;
    outline: 5px dashed magenta;
}

http://jsfiddle.net/loren_hibbard/uKGCc/

This just changes the outline immediately..

Thanks

‑‑‑‑‑

參考解法

方法 1:

If you want to apply multiple different transitions, you have to coalesce them into one rule (plus repeat them with the necessary prefixes):

‑webkit‑transition: color 2s, outline‑color .7s ease‑out, background‑color .7s ease‑out;
   ‑moz‑transition: color 2s, outline‑color .7s ease‑out, background‑color .7s ease‑out;
     ‑o‑transition: color 2s, outline‑color .7s ease‑out, background‑color .7s ease‑out;
        transition: color 2s, outline‑color .7s ease‑out, background‑color .7s ease‑out;

Example: http://jsfiddle.net/UF3Ht/6/

https://developer.mozilla.org/en‑US/docs/CSS/transition‑property

transition:
   [<'transition‑property'> || <'transition‑duration'> || <'transition‑timing‑function'> || <'transition‑delay'> 
[, [<'transition‑property'> || <'transition‑duration'> || <'transition‑timing‑function'> || <'transition‑delay'>]]*

When you use the same property multiple times, only the last one will be applied as usual:

transition: outline‑color .7s ease‑out;    /* this will be overridden */
transition: background‑color .7s ease‑out; /* this will be used */

(by 1252748biziclop)

參考文件

  1. possible to transition outline color with css3 (CC BY‑SA 3.0/4.0)

#css #html






相關問題

在圖像上淡入文本 (Fade in text over an image)

可以使用 css3 轉換輪廓顏色 (possible to transition outline color with css3)

以背景色為條件的 if 語句 (If statement with background color as condition)

Nội dung từ <p> biến mất khi tôi quay lại trang (Content from <p> disappears when I return to the page)

當按鈕向右浮動時,ng-click 不起作用 (ng-click doesn't work when the button is floated to the right)

帶有偽 css 的背景顏色層 (Background color layer with pseudo css)

是否可以製作離線工作的網絡應用程序? (Is it possible to make a web-app which works offline?)

chrome中帶有省略號的多行文本問題 (issue with multiline text with ellipsis in chrome)

將字符串轉換為類的安全名稱 (Convert string to safe name for class)

絕對定位跨度收縮 (Absolute Positioned Span Shrinks)

如何設置單選按鈕的樣式,使其看起來像普通的可點擊按鈕? (How do I style a radio button to look like a normal clickable button?)

無法獲得白色和灰色的 CSS 進度條 (Not able to get the CSS progress bar with white and grey)







留言討論