- hover至每一個項目時會有以下的transition
- 在整個
stream-item
加上filter: contrast(125%) brightness(150%);
做對比與亮度的增強 - 在整個
stream-item
加上box-shadow: 5px 5px 20px 2.5px #323232;
做邊框深灰陰影 - 在
content
加上hover時背景為全黑無透明 - 第一項目加入
id="special"
demo移過去一秒後發生hover效果 transition
這個屬性加在.class
上跟加在.class:hover
上面是不一樣,欲使移入移出皆有效果,就需要加在.class
上- 加入一些sass語法
試著在preview
下的content
處加入如下程式,使content
在hover時背景為全黑無透明
.content:hover {
background-color: rgba(0, 0, 0, 1)
transition: background-color .25s
}
在:hover
處加上transition-delay: 1s;
.stream-item:hover {
box-shadow: 5px 5px 20px 2.5px #323232;
filter: contrast(125%) brightness(150%);
transition: box-shadow .25s, filter .5s;
}
#special:hover {
transition-delay: 1s;
}
I. performance不佳
II. 使用transition: all
意義為「所有transition效果共享同樣的延續時間以及速率變換方式」,有時候會因為載入速度不一致而造成UX不佳
Yes, using
transition: all
could cause major drawbacks in performance. There can be a lot of cases where the browser would look if it needs to make a transition, even if user won't see it, like the color changes, dimension changes etc.The simplest example I can think of is this: http://dabblet.com/gist/1657661 — try to change the zoom level or the font's size and you'll see that everything become animated.Of course there couldn't be a lot of such user interactions, but there could be some interface changes that can cause the reflow and repaints in some blocks, that could tell the browser to try and animate those changes.
So, in general, it's recommended that you won't use the transition: all and would use the direct transitions instead.
There are some other things that can go wrong with the all transitions, like the splash of animation on page load, where it would at first render the initial styles for blocks and then apply the style with an animation. In a lot of cases it wouldn't be the thing that you want :)
CSS3 Transitions: Is “transition: all” slower than “transition: x”?
- 目前只使用Chrome開發,在使用Safari檢視時transition稍微有些頓
- 改為
flexbox
的關係,在寬度小於1400的display上會有排版上的bug
https://dezchuang.github.io/frontend-intermediate-course/answers/hw2/index.html