div+css布局实现彩色方块玻璃效果代码

代码语言:html

所属分类:布局界面

代码描述:div+css布局实现彩色方块玻璃效果代码

代码标签: div css 布局 彩色 方块 玻璃

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">

  
  
  
<style>
.box {
  --bgc: hsl(0 0% 100%);
  width: 10rem;
  aspect-ratio: 1/1;
  border: 1.5rem solid #0000;
  background:
    linear-gradient(120deg,
      color-mix(in oklab, var(--bgc), hsl(0 0% 0%) 10%) calc(50% - 1px),
      var(--bgc) calc(50% + 1px)
    ) border-box;
  position: relative;
  isolation: isolate;
  &::before{
    content: "";
    inset: 0;
    position: absolute;
    z-index: -1;
    border-radius: 2px;
    background-color: hsl(0 0% 100% / .25);
    backdrop-filter: blur(4px);
    box-shadow: 
      inset 1px 1px hsl(0 0 100% / .25),
      inset -1px -1px hsl(0 0 0% / .25),
      10px 10px 10px hsl( 0 0 0% / .25)
  }
}

*, *::before, *::after { box-sizing: border-box }
html, body { height: 100% }
html { color-scheme: dark }
body {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  padding: 2rem;
  align-items: center;
  justify-content: center;
  font-family: system-ui, sans-serif
}
</style>


  
  
</head>

<body translate="no">
  <div class="box"></div>
<div class="box" styl.........完整代码请登录后点击上方下载按钮下载查看

网友评论0