CSS圖片唯美特效常用于網頁設計,可以給頁面增添更多的美感和藝術感。下面介紹幾種常見的CSS圖片唯美特效。
/* 遮罩特效 */ img{ position: relative; max-width: 100%; } img::before{ content: ""; display: block; position: absolute; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.3s ease-in-out; } img:hover::before{ opacity: 1; } /* 模糊特效 */ img{ position: relative; max-width: 100%; } img:hover{ filter: blur(5px); transition: filter 0.3s ease-in-out; } /* 翻轉特效 */ .flip-box{ perspective: 1000px; } .flip-box-inner{ position: relative; width: 100%; height: 0; padding-bottom: 100%; transform-style: preserve-3d; } .flip-box-hover .flip-box-inner{ transform: rotateY(180deg); } .flip-box-front, .flip-box-back{ position: absolute; width: 100%; height: 100%; backface-visibility: hidden; } .flip-box-front{ background-image: url("front.jpg"); background-size: cover; z-index: 2; } .flip-box-back{ background-image: url("back.jpg"); background-size: cover; transform: rotateY(180deg); z-index: 1; } .flip-box:hover .flip-box-inner{ transform: rotateY(180deg); } /* 變形特效 */ img{ position: relative; max-width: 100%; } img:hover{ transform: skew(20deg); transition: transform 0.3s ease-in-out; }
CSS圖片唯美特效可以通過遮罩、模糊、翻轉和變形等手法實現。以上代碼可以在圖片上添加遮罩、模糊、翻轉和變形等特效。讀者可以根據需要進行相應的修改,以達到預期的效果。