open-props+css实现列表增加删除元素自适应布局动画效果代码

代码语言:html

所属分类:布局界面

代码描述:open-props+css实现列表增加删除元素自适应布局动画效果代码

代码标签: open-props css 列表 增加 删除 元素 自适应 布局 动画

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

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

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

  <meta name="viewport" content="width=device-width, initial-scale=1">
  
  
  
<style>
@import "//repo.bfw.wiki/bfwrepo/css/open-props.1.6.17.css" layer(design.system);
@import "//repo.bfw.wiki/bfwrepo/css/open-props.normalize.min.css" layer(demo.support);
@import "//repo.bfw.wiki/bfwrepo/css/open-props.buttons.css" layer(demo.support);

@layer demo {
  .container {
    /* VERY IMPORTANT this is "size" and not "inline-size" */
    /* it unlocks container aspect ratio queries */
    container: perfect-bento / size;
  }
  
  .always-great-grid {
    /* these are all the quantity queries */
    /* how the grid knows the # of boxes */
    /* some target the grid itself */
    /* some target the :first-child */
    
    &:has(> :last-child:nth-child(3)) > :first-child {
      grid-column: span 2;
    }
    
    &:has(> :last-child:nth-child(4)) {
      grid-template-columns: repeat(2, 1fr);
    }
    
    &:has(> :last-child:nth-child(5)) > :first-child {
      grid-column: span 2;
    }
    
    &:has(> :last-child:nth-child(6)) {
      grid-template-columns: repeat(2, 1fr);
    }
    
    &:has(> :last-child:nth-child(7)) > :first-child {
      grid-column: span 2;
      grid-row: span 2;
    }
    
    &:has(> :last-child:nth-child(8)) {
      grid-template-columns: repeat(2, 1fr);
    }
    
    &:has(> :last-child:nth-child(9)) {
      grid-template-columns: repeat(3, 1fr);
    }
    
    &:has(> :last-child:nth-child(10)) {
      grid-template-columns: repeat(2, 1fr);
    }
    
    &:has(> :last-child:nth-child(11)) > :first-child {
      grid-column: span 2;
      grid-row: span 2;
    }
    
    &:has(> :last-child:nth-child(12)) {
      grid-template-columns: repeat(4, 1fr);
    }
    
    /* here's where the layout is adapted if landscape */
    @container perfect-bento (orientation: landscape) {
      grid-auto-flow: column;
      grid-auto-columns: 1fr;
      
      &:has(> :last-child:nth-child(3)) {
        grid-template-columns: repeat(4, 1fr);
      }
      
      &:has(> :last-child:nth-child(5)) > :first-child {
        grid-column: initial;
        grid-row: span 2;
      }
      
      &:has(> :last-child:nth-child(6)),
      &:has(> :last-child:nth-child(8)),
      &:has(> :last-child:nth-child(10)),
      &:has(> :last-child:nth-child(12)) {
        grid-template-rows: repeat(2, 1fr);
      }
      
      &:has(> :last-child:nth-child(9)) > :first-child {
        grid-column: span 2;
        grid-row: span 2;
      }
    }
  }
}

@layer demo.transitions {
  /* this makes the view transition (VT) pseudo elements not steal clicks */
  ::view-transition {
    pointer-events: none;
  }
  
  /* removes view transition on the page */
  /* helps isolate the morph effect to the grid */
  :root {
    view-transition-name: none;
  }
  
  /* make all the VT animations springy! */
  ::view-transition-group(*) {
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0