重点:(用display时)
transition过渡不生效 所以我们需要使用animation动画生效
代码示例:
去掉.jf-drawer-container-hide类后,帧动画生效
.jf-drawer-container { display: block; position: fixed; z-index: 2000; width: 100%; height: 100%; box-sizing: border-box; overflow: hidden; background-color: #ccc; } .jf-drawer-container-hide { display: none; } .jf-drawer-panel { width: 200px; background-color: red; animation: s 2s; } @keyframes s { from { transform: translateX(-100%); } to { transform: translateX(0%); } }