不使用字体图标和图片,只使用css如何做出展开收起的效果
<i class="iconArrow" :class="[ littleNavState === item.meta.id ? ‘arrowOpen‘ : ‘‘ ]"></i>
默认效果
.iconArrow { position: absolute; top: 50%; right: 16px; width: 10px; -webkit-transition: -webkit-transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); transition: -webkit-transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); transition: transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); transition: transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), -webkit-transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); } .iconArrow::before, .iconArrow::after { position: absolute; width: 6px; height: 1.5px; background: #fff; background: rgba(0, 0, 0, 0.65) \9; background-image: -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, 0.65)), to(rgba(0, 0, 0, 0.65))); background-image: linear-gradient(to right, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0.65)); background-image: none \9; border-radius: 2px; -webkit-transition: background 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), top 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), -webkit-transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); transition: background 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), top 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), -webkit-transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); transition: background 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), top 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); transition: background 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), top 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), -webkit-transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); content: ‘‘; } .iconArrow::before { -webkit-transform: rotate(45deg) translateY(-2px); -ms-transform: rotate(45deg) translateY(-2px); transform: rotate(45deg) translateY(-2px); } .iconArrow::after { -webkit-transform: rotate(-45deg) translateY(2px); -ms-transform: rotate(-45deg) translateY(2px); transform: rotate(-45deg) translateY(2px); } .nav > li:hover .iconArrow::after, .nav > li:hover .iconArrow::before { background: -webkit-gradient(linear, left top, right top, from(#1890ff), to(#1890ff)); background: linear-gradient(to right, #1890ff, #1890ff); } .iconArrow::before { -webkit-transform: rotate(-45deg) translateX(2px); -ms-transform: rotate(-45deg) translateX(2px); transform: rotate(-45deg) translateX(2px); } .iconArrow::after { -webkit-transform: rotate(45deg) translateX(-2px); -ms-transform: rotate(45deg) translateX(-2px); transform: rotate(45deg) translateX(-2px); }
收起效果
.iconArrow.arrowOpen { -webkit-transform: translateY(-2px); -ms-transform: translateY(-2px); transform: translateY(-2px); } .iconArrow.arrowOpen::after { -webkit-transform: rotate(-45deg) translateX(-2px); -ms-transform: rotate(-45deg) translateX(-2px); transform: rotate(-45deg) translateX(-2px); } .iconArrow.arrowOpen::before { -webkit-transform: rotate(45deg) translateX(2px); -ms-transform: rotate(45deg) translateX(2px); transform: rotate(45deg) translateX(2px); }
相关推荐
yaodilu 2020-04-30
sunshineboyleng 2020-07-08
impress 2020-05-11
/*垂直居中,div上边界距离窗口上边的距离为窗口高度的50%,并针对不同浏览器进行兼容。-- 在外层添加一个div,把行内容居中,添加.row .justify-content-center -->
Phoebe的学习天地 2020-04-14
福叔 2020-04-11
zjuwangleicn 2020-03-08
冰蝶 2020-03-01
somboy 2020-02-29
zengni 2020-02-23
wangjie 2020-02-22
冰蝶 2020-02-16
lanzhusiyu 2020-02-03
lanzhusiyu 2020-01-12
MaureenChen 2020-01-01
jiedinghui 2019-12-27
zhanghao 2019-12-20
bertzhang 2019-12-14
impress 2019-12-13