Last active
January 16, 2018 00:06
-
-
Save Rplus/884b561e7a5d42249e02 to your computer and use it in GitHub Desktop.
Medium picture figure snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<figure name="322b" id="322b" class="graf--figure graf-after--h3"> | |
<div class="aspectRatioPlaceholder is-locked" style="max-width: 700px; max-height: 389px;"> | |
<div class="aspect-ratio-fill" style="padding-bottom: 55.60000000000001%;"></div> | |
<div class="progressiveMedia js-progressiveMedia graf-image" | |
data-image-id="1*vRzbJmu0VC5yWRWbc7d-0w.png" | |
data-width="955" data-height="531" | |
data-action="zoom" data-action-value="1*vRzbJmu0VC5yWRWbc7d-0w.png"> | |
<img src="https://cdn-images-1.medium.com/freeze/max/33/1*vRzbJmu0VC5yWRWbc7d-0w.png?q=20" | |
crossorigin="anonymous" class="progressiveMedia-thumbnail js-progressiveMedia-thumbnail"> | |
<canvas class="progressiveMedia-canvas js-progressiveMedia-canvas"></canvas> | |
<img class="progressiveMedia-image js-progressiveMedia-image" | |
data-src="https://cdn-images-1.medium.com/max/880/1*vRzbJmu0VC5yWRWbc7d-0w.png"> | |
<noscript class="js-progressiveMedia-inner"> | |
<img class="progressiveMedia-noscript js-progressiveMedia-inner" src="https://cdn-images-1.medium.com/max/880/1*vRzbJmu0VC5yWRWbc7d-0w.png"> | |
</noscript> | |
</div> | |
</div> | |
<figcaption class="imageCaption"> | |
The previous Salesforce1 style guide | |
</figcaption> | |
</figure> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.aspect-ratio-fill
的padding-bottom
數值應該處理一下小數位數比較好,一般來說兩三位應該就夠用了
這玩意主要就是把高度撐起來
因為後面主要呈現的圖樣區塊是用
position: absolute
處理的原圖寬高在 server side 已經有給出了
雖然不確定是 server 動態算還是在上傳時就有記進去
總之這寬高比數值在處理 RWD image 是個關鍵點
不然頁面會跳來跳去的,很影響觀感
這值其實也可以丟給
<noscript>
裡的 img 寬高,但也不是必要就是了接下來重點是 RWD image 的格式
class="progressiveMedia-thumbnail js-progressiveMedia-thumbnail"
這張是小圖主要是拿來餵
<canvas>
的真正大圖是有
data-src
attribute 的圖片等它 onload 後才算真的把圖載進來了
HTML 原始碼的部份大抵就是這樣