css实现图片卡片文字悬浮动画效果
代码语言:html
所属分类:悬停
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title> Izmir - ImageHover CSS Library - Example 1</title> <style> @import url('https://fonts.googleapis.com/css?family=Noto+Sans+HK:300,400,700&display=swap'); html { height: 100%; } /*! CSS Used from demo.css */ body { background-color: #212121; display: flex; justify-content: center; align-items: center; flex-flow: wrap; margin: 0; height: 100%; font-family: 'Noto Sans HK', sans-serif; font-weight: 300; } .wrapper { width: 100%; max-width: 1080px; } .examples { display: flex; flex-wrap: wrap; justify-content: center; } .examples > * { margin: 8px; max-width: 330px; } h4 { font-size: 1.4em; } a { color: #059BC6; } .text { color: #fff; text-align: center; margin-bottom: 30px; } .text h2 { font-weight: 300; font-size: 2em; text-transform: capitalize; } .text h3 { font-weight: 300; font-size: 1.3em; } .text strong { font-weight: 700; color: #059BC6; } /*! CSS Used from izmir.css */ .ls-izmir { --text-color: #ffffff; --primary-color: #00B4DB; --secondary-color: #0083B0; --padding: 1em; --transition-duration: 600ms; --border-margin: 15px; --border-width: 3px; --border-color: #ffffff; --border-radius: 3px; --image-opacity: 0.25; display: inline-flex; position: relative; box-sizing: border-box; overflow: hidden; margin: 0; padding: 0; color: #ffffff; color: var(--text-color); border-radius: 3px; border-radius: var(--border-radius); } .ls-izmir:before,.ls-izmir:after,.ls-izmir *,.ls-izmir *:before,.ls-izmir *:after { box-sizing: border-box; transition: all 600ms ease; transition: all var(--transition-duration) ease; } .ls-izmir figcaption { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 1em; padding: var(--padding); width: 100%; z-index: 1; } .ls-izmir img { object-fit: cover; max-width: 100%; width: 100%; height: 100%; } .ls-izmir h4 { margin-top: 0; color: #ffffff; color: var(--text-color); } .ls-izmir h4:last-child { margin-bottom: 0; } [class*=' ls-border']:before,[class*=' ls-border']:after,[class*=' ls-border'] figcaption:before,[class*=' ls-border'] figcaption:after { background-color: #ffffff; background-color: var(--border-color); position: absolute; content: ''; } [class*=' ls-border']:before,[class*=' ls-border']:after { z-index: 1; height: 3px; height: var(--border-width); left: 15px; left: var(--border-margin); right: 15px; right: var(--border-margin); transform: scaleX(0); } [class*=' ls-border']:before { top: 15px; top: var(--border-margin); } [class*=' ls-border']:after { bottom: 15px; bottom: var(--border-margin); } [class*=' ls-border'] figcaption { z-index: 3; } [class*=' ls-border'] figcaption:before,[class*=' ls-border'] figcaption:after { z-index: -1; width: 3px; width: var(--border-width); top: 15px; top: var(--border-margin); bottom: 15px; bottom: var(--border-margin); transform: scaleY(0); } [class*=' ls-border'] figcaption:before { left: 15px; left: var(--border-margin); } [class*=' ls-border'] figcaption:after { right: 15px; right: var(--border-margin); } [class*=' ls-border'].hover:before,[class*=' ls-border'].hover:after,[class*=' ls-border'].hover figcaption:before,[class*=' ls-border'].hover figcaption:after,[class*=' ls-border']:hover:before,[class*=' ls-border']:hover:after,[class*=' ls-border']:hover figcaption:before,[class*=' ls-border']:hover figcaption:after,[class*=' ls-border']:focus:before,[class*=' ls-border']:focus:after,[class*=' ls-border']:focus figcaption:before,[class*=' ls-border']:focus figcaption:after,.........完整代码请登录后点击上方下载按钮下载查看
网友评论0