如何在不破壞容器邊界半徑的情況下創建與 Safari 兼容的過渡變換比例 (How would I create a Safari-compatible Transition Transform Scale without breaking the container's border-radius)


問題描述

如何在不破壞容器邊界半徑的情況下創建與 Safari 兼容的過渡變換比例 (How would I create a Safari‑compatible Transition Transform Scale without breaking the container's border‑radius)

我有一張想在懸停時縮放的圖片。圖像的容器有一個邊界半徑。圖像在大多數瀏覽器上都可以很好地縮放,但在 Safari 上,容器的邊框半徑在應用過渡時會被刪除。我創建了一個 jsfiddle 來展示這種行為。

https://jsfiddle.net/jt9u7qhw/

我嘗試在有和沒有 webkit 的情況下應用特定屬性 transform 和 border‑radius 的過渡時間,

.element {
    transition: transform 1s, border‑radius 1s;
    ‑webkit‑transition: transform 1s, border‑radius 1s;
    transition‑duration: 1s;
    ‑webkit‑transition‑duration: 1s;
}

但這並沒有什麼不同,我該怎麼做在此過渡期間保留邊界半徑?


參考解法

方法 1:

Although this breaks using transform: scale and ‑webkit‑transition: transform 1s, border‑radius 1s or ‑webkit‑transition: all 1s a potential workaround since this is using backround images is to change the background size on hover instead of scaling it up,

.element {
background‑size: auto 100%; # set width to auto works in this case b/c landscape pic
‑webkit‑transition: all 1s ease‑out;
transition: all 1s ease‑out;
}

.container:hover .element,
.container:focus .element {
background‑size: auto 110%;
}
</code></pre>

Working demo, https://jsfiddle.net/khzu0t61/

(by LyresLyres)

參考文件

  1. How would I create a Safari‑compatible Transition Transform Scale without breaking the container's border‑radius (CC BY‑SA 2.5/3.0/4.0)

#css #scale #border-radius #transition #transform






相關問題

在圖像上淡入文本 (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)







留言討論