css+js实现可伸缩右边栏grid网格布局效果代码
代码语言:html
所属分类:布局界面
代码描述:css+js实现可伸缩右边栏grid网格布局效果代码
代码标签: css js 可伸缩 右边栏 grid 网格 布局
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { --move-duration: 0.3s; } body { height: 100vh; margin: 0; display: grid; place-items: center; background: linear-gradient( 135deg, #FFF, #DAEEEE ); font-family: monospace; } button { -webkit-appearance: none; -moz-appearance: none; appearance: none; border: none; font: inherit; color: inherit; background: transparent; } .icon { color: #7a8a90; transition: all .3s; } .container { --gutter: 1em; display: grid; grid-template-columns: 2fr 1fr; width: clamp(180px, 50vmin, 360px); padding: var(--gutter); gap: var(--gutter); background: #fff; border-radius: 2em; box-shadow: .1em .1em .3em #0001; } .region { --region-bg: #DAEEEEAA; display: flex; justify-content: center; align-items: center; padding: 1em; text-align: center; background: var(--region-bg); font-variant: small-caps; letter-spacing: .1em; color: #88a5a9; } .header { min-height: 5vh; grid-column: span 2; border-top-left-radius: 1em; border-top-right-radius: 1em; } .with-long-aside .header { grid-row: 1; grid-column: 1; border-top-right-radius: 0; -webkit-animation: pulse linear forwards 0.5s; animation: pulse linear forwards 0.5s; } @-webkit-keyframes pulse { 20% { background: lemonchiffon; } to { background: var(--region-bg); } } @keyframes pulse { 20% { background: lemonchiffon; } to { background: var(--region-bg); } } .header-label { display: flex; justify-content: flex-end; min-width: 1%; transition: all .5s; } .with-long-aside .header-label { -webkit-animation: move-left-header-label var(--move-duration) forwards; animation: move-left-header-label var(--move-duration) forwards; } .without-long-aside .header-label { justify-content: flex-start; -webkit-animation: move-right-header-label var(--move-duration) forwards; animation: move-right-header-label var(--move-duration) forwards; } @-webkit-keyframes move-left-header-label { from { min-width: 85%; } to { min-width: 1%; } } @keyframes move-left-header-label { from { min-width: 85%; } to { min-width: 1%; } } @-webkit-keyframes move-right-header-label { from { min-width: 52%; } to { min-width: 1%; } } @keyframes move-right-header-label { from { min-width: 52%; } to { min-width: 1%; } } .main { min-height: 25vh; } .aside { position: relative; padding: 0; } .aside:hover { box-shadow: inset 0 0 5em .1em #0351; } .with-long-aside .aside { grid-row: 1 / 3; border-top-right-radius: 1em; -webkit-animation: pulse linear forwards 0.5s; animation: pulse linear forwards 0.5s; } .aside button { display: flex; justify-content: center; align-items: center; padding: 1em; text-align: center; width: 100%; height: 100%; cursor: pointer; } .aside-label { display: flex; align-items: flex-end; min-height: 1%; transition: all .5s; } .with-long-aside .aside-label { -webkit-animation: move-up-aside-label var(--move-duration) forwards; animation: move-up-aside-label var(--move-duration) forwards; } .without-long-aside .aside-label { align-items: flex-start; -webkit-animation: move-down-aside-label var(--move-duration) forwards; animation: move-down-aside-label var(--move-duration) forwards; } @-webkit-keyframes move-up-aside-label { from { min-height: 32%; } to { min-height: 1%; } } @keyframes move-up-aside-label { from { min-height: 32%; } to { min-height: 1%; } } @-webkit-keyframes move-down-aside-label { from { min-height: 44%; } to { min-height: 1%; } } @keyframes move-down-aside-label { from { min-height: 44%; } to { min-height: 1%; } } .aside-instructions { position: absolute; bottom: 1em; width: 100%; display: flex; justify-content: space-evenly; align-items: center; transition: all .3s; } @media (max-height: 400px) { .aside-instructions { display: none; } } .click-icon, .chevron-icon, .chevron-contour-icon { width: max(3vmin, 14px); height: max(3vmin, 14px); transition: all .2s.........完整代码请登录后点击上方下载按钮下载查看
网友评论0