flex实现骰(tou)子点数

2024-08-30 09:20
文章标签 实现 点数 flex tou

本文主要是介绍flex实现骰(tou)子点数,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

  • 效果演示
  • 分析思路
  • 代码实现

效果演示

在这里插入图片描述

分析思路

image-20240202213028669
5点需要使用margin进行移动点数。而6点的话,使用align-content: space-between; justify-content: space-between;就能实现,不过需要注意的是主轴为侧轴,dot的第二个要给padding才能实现每一列3个点。

代码实现

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>骰子点数</title><style>* {margin: 0;padding: 0;box-sizing: border-box;}.wrapper {margin: 100px 100px;width: 800px;height: 500px;border-radius: 10px;background-color: #232323;display: flex;flex-wrap: wrap;align-items: center;justify-content: space-around;}.dot {width: 20px;height: 20px;border-radius: 50%;background-color: #000;}.box-common {width: 100px;height: 100px;display: flex;background-color: #fff;padding: 4px;margin: 60px;border-radius: 8px;}/* 1点的写法 主轴与侧轴垂直 */.box1 {align-items: center;justify-content: center;}/* 2点的写法 主轴为侧轴 两端对齐 首尾对齐 */.box2 {flex-direction: column;justify-content: space-between;align-items: center;}/* align-self子元素属性,控制自身的排列 */.dot2-1 {align-self: flex-start;}/* align-self子元素属性,控制自身的排列 */.dot2-2 {align-self: flex-end;}/* 3点的写法 */.box3 {justify-content: space-between;}.dot3-1 {align-self: flex-start;}.dot3-2 {align-self: center;}.dot3-3 {align-self: flex-end;}/* 4点写法 */.box4 {flex-wrap: wrap;}.dot4 {width: 50%;height: 50%;display: flex;}.dot4:nth-child(2) {justify-content: flex-end;}.dot4:nth-child(3) {align-items: flex-end;}.dot4:nth-child(4) {justify-content: flex-end;align-items: flex-end;}/* 5点写法 */.box5 {flex-wrap: wrap;justify-content: center;align-content: space-between;}.dot5:nth-child(1) {margin-right: 40px;}.dot5:nth-child(3) {margin-left: 40px;margin-right: 40px;align-self: center;}.dot5:nth-child(4) {margin-right: 40px;}/* 6点写法 */.box6 {display: flex;flex-direction: column;flex-wrap: wrap;align-content: space-between;justify-content: space-between;}.dot6:nth-child(2) {padding: 10px 0;}</style></head><body><div class="wrapper"><!-- 一点 父容器,主轴居中,侧轴居中--><div class="box1 box-common"><div class="dot"></div></div><!-- 二点 主容器主轴为侧轴,居中,每一个子项单独控制,第一个flex-start,第二个flex-end--><div class="box2 box-common"><div class="dot dot2-1"></div><div class="dot dot2-2"></div></div><!-- 三点 同2点写法一样,只不过中间的点是center--><div class="box3 box-common"><div class="dot dot3-1"></div><div class="dot dot3-2"></div><div class="dot dot3-3"></div></div><!-- 四点 分为四个部分,嵌套两层flex盒子--><div class="box4 box-common"><div class="dot4"><div class="dot"></div></div><div class="dot4"><div class="dot"></div></div><div class="dot4"><div class="dot"></div></div><div class="dot4"><div class="dot"></div></div></div><!-- 5点写法 --><div class="box5 box-common"><div class="dot5"><div class="dot"></div></div><div class="dot5"><div class="dot"></div></div><div class="dot5"><div class="dot"></div></div><div class="dot5"><div class="dot"></div></div><div class="dot5"><div class="dot"></div></div></div><!-- 六点写法 --><div class="box6 box-common"><div class="dot6"><div class="dot"></div></div><div class="dot6"><div class="dot"></div></div><div class="dot6"><div class="dot"></div></div><div class="dot6"><div class="dot"></div></div><div class="dot6"><div class="dot"></div></div><div class="dot6"><div class="dot"></div></div></div></div></body>
</html>

这篇关于flex实现骰(tou)子点数的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1120421

相关文章

基于C++的UDP网络通信系统设计与实现详解

《基于C++的UDP网络通信系统设计与实现详解》在网络编程领域,UDP作为一种无连接的传输层协议,以其高效、低延迟的特性在实时性要求高的应用场景中占据重要地位,下面我们就来看看如何从零开始构建一个完整... 目录前言一、UDP服务器UdpServer.hpp1.1 基本框架设计1.2 初始化函数Init详解

Java中Map的五种遍历方式实现与对比

《Java中Map的五种遍历方式实现与对比》其实Map遍历藏着多种玩法,有的优雅简洁,有的性能拉满,今天咱们盘一盘这些进阶偏基础的遍历方式,告别重复又臃肿的代码,感兴趣的小伙伴可以了解下... 目录一、先搞懂:Map遍历的核心目标二、几种遍历方式的对比1. 传统EntrySet遍历(最通用)2. Lambd

springboot+redis实现订单过期(超时取消)功能的方法详解

《springboot+redis实现订单过期(超时取消)功能的方法详解》在SpringBoot中使用Redis实现订单过期(超时取消)功能,有多种成熟方案,本文为大家整理了几个详细方法,文中的示例代... 目录一、Redis键过期回调方案(推荐)1. 配置Redis监听器2. 监听键过期事件3. Redi

SpringBoot全局异常拦截与自定义错误页面实现过程解读

《SpringBoot全局异常拦截与自定义错误页面实现过程解读》本文介绍了SpringBoot中全局异常拦截与自定义错误页面的实现方法,包括异常的分类、SpringBoot默认异常处理机制、全局异常拦... 目录一、引言二、Spring Boot异常处理基础2.1 异常的分类2.2 Spring Boot默

基于SpringBoot实现分布式锁的三种方法

《基于SpringBoot实现分布式锁的三种方法》这篇文章主要为大家详细介绍了基于SpringBoot实现分布式锁的三种方法,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录一、基于Redis原生命令实现分布式锁1. 基础版Redis分布式锁2. 可重入锁实现二、使用Redisso

SpringBoo WebFlux+MongoDB实现非阻塞API过程

《SpringBooWebFlux+MongoDB实现非阻塞API过程》本文介绍了如何使用SpringBootWebFlux和MongoDB实现非阻塞API,通过响应式编程提高系统的吞吐量和响应性能... 目录一、引言二、响应式编程基础2.1 响应式编程概念2.2 响应式编程的优势2.3 响应式编程相关技术

C#实现将XML数据自动化地写入Excel文件

《C#实现将XML数据自动化地写入Excel文件》在现代企业级应用中,数据处理与报表生成是核心环节,本文将深入探讨如何利用C#和一款优秀的库,将XML数据自动化地写入Excel文件,有需要的小伙伴可以... 目录理解XML数据结构与Excel的对应关系引入高效工具:使用Spire.XLS for .NETC

Nginx更新SSL证书的实现步骤

《Nginx更新SSL证书的实现步骤》本文主要介绍了Nginx更新SSL证书的实现步骤,包括下载新证书、备份旧证书、配置新证书、验证配置及遇到问题时的解决方法,感兴趣的了解一下... 目录1 下载最新的SSL证书文件2 备份旧的SSL证书文件3 配置新证书4 验证配置5 遇到的http://www.cppc

Nginx之https证书配置实现

《Nginx之https证书配置实现》本文主要介绍了Nginx之https证书配置的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起... 目录背景介绍为什么不能部署在 IIS 或 NAT 设备上?具体实现证书获取nginx配置扩展结果验证

SpringBoot整合 Quartz实现定时推送实战指南

《SpringBoot整合Quartz实现定时推送实战指南》文章介绍了SpringBoot中使用Quartz动态定时任务和任务持久化实现多条不确定结束时间并提前N分钟推送的方案,本文结合实例代码给大... 目录前言一、Quartz 是什么?1、核心定位:解决什么问题?2、Quartz 核心组件二、使用步骤1