当前位置: 首页 > article >正文

css 十字分割线(含四等分布局)

在这里插入图片描述

核心技术

伪类选择器含义
li:nth-child(2)第2个 li
li:nth-child(n)所有的li
li:nth-child(2n)所有的第偶数个 li
li:nth-child(2n+1)所有的第奇数个 li
li:nth-child(-n+5)前5个 li
li:nth-last-child(-n+5)最后5个 li
li:nth-child(7n)选中7的倍数
    border-right: 3px solid white;
    border-top: 3px solid white;
    // 父元素中的偶数个子元素
    &:nth-child(2n) {
      border-right: 0 none;
    }
    // 父元素的前两个子元素(即第1和第2个item)
    &:nth-child(-n + 2) {
      border-top: 0 none;
    }

完整代码范例

<template>
  <div class="container">
    <div class="item">1</div>
    <div class="item">2</div>
    <div class="item">3</div>
    <div class="item">4</div>
  </div>
</template>

<style lang="scss" scoped>
.container {
  border: 3px solid red;
  width: 600px;
  height: 300px;
  margin: 30px;
  display: flex;
  flex-wrap: wrap;
  .item {
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    width: 50%;
    height: 50%;
    background-color: yellow;
    border-right: 3px solid white;
    border-top: 3px solid white;
    // 父元素中的偶数个子元素
    &:nth-child(2n) {
      border-right: 0 none;
    }
    // 父元素的前两个子元素(即第1和第2个item)
    &:nth-child(-n + 2) {
      border-top: 0 none;
    }
  }
}
</style>


http://www.kler.cn/news/162675.html

相关文章:

  • Python-链式调用详解(默认参数,函数的嵌套调用、关键字传参)
  • xxl-job详解
  • RestTemplate硬编码的使用
  • C++STL的string模拟实现
  • 实现SQL server数据库完整性
  • 进程控制与原语
  • Termux+Hexo结合内网穿透轻松实现安卓手机搭建博客网站发布公网访问
  • 这把养生局~
  • Vue 子路由页面发消息给主路由页面 ,实现主页面显示子页面的信息
  • [架构之路-258]:目标系统 - 设计方法 - 软件工程 - 软件设计 - 架构设计 - 软件架构与软件框架的详细比较
  • 倒计时模块复习
  • 一篇文章带你快速入门 Vue 核心语法
  • chfs,简单好用的局域网共享网盘
  • 设计并实现一个多线程图书馆管理系统,涉及数据库操作
  • python圣诞树代码编程
  • HarmonyOS
  • JVM GUI可视化监控及诊断工具
  • Python语言基础知识(二)
  • 【S32DS报错】-2-提示Error while launching command:arm-none-eabi-gdb –version错误
  • DeepIn,UOS统信专业版安装运行Java,JavaFx程序
  • LeetCode-496. 下一个更大元素 I【栈 数组 哈希表 单调栈】
  • pip的常用命令
  • 获取系统固件类型和Windows固件API学习
  • 行云海CMS SQL注入漏洞复现
  • GO -- 设计模式
  • 如何使用技术 SEO 优化 Pinterest 富图钉
  • JVM虚拟机:如何查看JVM初始和最终的参数?
  • 管理类联考——数学——真题篇——按题型分类——充分性判断题——秒杀
  • 论文阅读《Learning Adaptive Dense Event Stereo from the Image Domain》
  • Orcal数据库Schema理解、表分区理解