高度宽度自定义百分比效果
代码语言:html
所属分类:布局界面
代码描述:高度宽度自定义百分比效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> * { box-sizing: border-box; margin: 0; padding: 0; } body { width: 100vw; min-height: 100vh; margin: 0; background-color: #291642; font-size: 100%; letter-spacing: 0.1rem; color: #fff; display: -webkit-box; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; flex-direction: column; -webkit-box-align: center; align-items: center; -webkit-box-pack: center; justify-content: center; background-blend-mode: hue; } .container { width: 500px; height: 200px; display: -webkit-box; display: flex; position: relative; margin-top: auto; box-shadow: 0 0 2px 0 #f36; } .container::before { content: "width: 500px"; position: absolute; bottom: 100%; left: 50%; -webkit-transform: translate(-50%, 0); transform: translate(-50%, 0); } .container::after { content: "height: 200px"; position: absolute; left: 100%; top: 50%; white-space: nowrap; -webkit-transform: translate(-40%, -50%) rotate(90deg); transform: translate(-40%, -50%) rotate(90deg); } .actions { padding: 3vh; display: -webkit-box; display: flex; -webkit-box-pack: center; justify-content: center; -webkit-box-align: center; align-items: center; background-color: rgba(0, 0, 0, 0.5); width: 100%; font-size: 2rem; margin-top: auto; } label:nth-of-type(2) { margin-left: 20px; } :root { --width: 50%; --height: 50%; } .element { width: var(--width); height: var(--height); background-color: #09f; } strong { color: #f89; } </style> </head> <body translate="no"> <div class="container"> <div class="element"></div> </div> <div class="actions"> <label for="width".........完整代码请登录后点击上方下载按钮下载查看
网友评论0