前言
@Heo博客的侧边栏有个可以hover旋转的公众号二维码卡片,我很想抄过来,冻手!
但Heo是直接放了个ps改好的图,我没有公众号,打算放博客链接的二维码,把图片p个二维码就用不上,自己做个图又嫌麻烦(弱弱的ps技术),还是用div+css去实现吧。
**效果:**因为不是图片,所以二维码可以根据页面的链接动态生成。
实现
新建\layout\includes\widget\card_tuijian.pug,放入以下内容。
.card-widget#card-tuijian #tj-box #tj-box1 #tj-left <p>扫一扫</p> <span>快速打开移动端➤</span> #tj-right #tj-img-box if is_home() img(src=qrcode(full_url_for(page.current_url),{margin:4})) else img(src=qrcode(full_url_for(page.path),{margin:4}))
#tj-box2 #tj-left <p>扫一扫</p> <span>下载移动端APP➤</span> #tj-right #tj-img-box img(src=qrcode("https://cdn.qcqx.cn/blog/app/chuckle.apk",{margin:4}))安装二维码生成插件。
npm i -S hexo-helper-qrcode 修改\layout\includes\widget\index.pug,在合适位置加入。
!=partial('includes/widget/card_tuijian', {}, {cache: false})CSS:
#card-tuijian#card-tuijian#card-tuijian#card-tuijian { background: linear-gradient(to right, #35bb99db, #2dbcc4db) !important; padding: 15px 0; height: 118px; -moz-user-select: none; -khtml-user-select: none; user-select: none;}
#card-tuijian #tj-box { width: 100%; height: 100%; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; transition: cubic-bezier(0, 0, 0, 1.29) 0.4s;}
#card-tuijian #tj-box2 { transform: rotateY(180deg); -webkit-transform: rotateY(180deg);}
#card-tuijian #tj-box1,#card-tuijian #tj-box2 { display: flex; justify-content: center; flex-wrap: nowrap; position: absolute; height: 100%; width: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden;}
#card-tuijian #tj-img-box { border-radius: 12px; margin-left: 10px; height: 85px;}
#card-tuijian #tj-img-box img { height: 85px; border-radius: 12px; filter: brightness(0.95) !important;}
#card-tuijian #tj-left { color: #fff; height: 85px;}
#card-tuijian #tj-left p { font-family: monospace, Arial; margin: 10px 0 0; font-size: 32px; line-height: normal; font-weight: 800; color: rgba(255, 255, 255, 0.9); text-shadow: -0.5px 0.5px 0 rgba(255, 255, 255, 0.9), 0.5px 0.5px 0 rgba(255, 255, 255, 0.9), 0.5px -0.5px 0 rgba(255, 255, 255, 0.9), -0.5px -0.5px 0 rgba(255, 255, 255, 0.9);}
#card-tuijian #tj-left span { font-size: 15px; font-weight: 800;}
#card-tuijian:hover #tj-box { -webkit-transform: rotateY(180deg); transform: rotateY(180deg); backface-visibility: hidden; -webkit-backface-visibility: hidden;}后记
2023-2-22:修改CSS,修复火狐浏览器下未能正确隐藏背面元素的bug
评论