EP02 | 跟著影片做前端切版練習 - CSS Wooden Text Typography Effects
練習影片
練習重點
background-clip : 限縮背景顏色的顯示區域。
background-size:cover:設置圖片大小,讓圖片放大到充滿整個元素。
background-attachment:fixed:讓該背景圖固定在瀏覽器可是區域內。
text-shadow:增加文字陰影。
架構
HTML
1 | <body> |
CSS
1 | @import url('https://fonts.googleapis.com/css2?family=Oswald:wght@700&display=swap'); |
小提醒
在使用 background-attachment:fixed
會發現,不論是在哪裡使用 background-attachment:fixed
,所有使用該屬性的背景圖片的基準點都是可視區域(viewport)左上角(就是從基準點將背景圖片放上去),所以在元素中圖片的顯示區域會是固定的,不因元素位置而有差別。
background-attachment:fixed
搭配 background-size: cover
使用的話,就能讓背景圖片充滿整個可視區域(viewport)。
Demo:
See the Pen 前端練習02 - Wooden Text Typography by Celeste6666 (@celeste6666) on CodePen.
Image by rawpixel.com - www.freepik.com