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

使用CSS常见问题解答卡片

常见问题解答卡片

效果展示

在这里插入图片描述

CSS 知识点

  • CSS 选择器的使用
  • background 渐变背景色运用
  • CSS 综合知识运用

页面整体布局

<div class="container"><h1>经常问的问题</h1><!-- 这里只是展示一个项目 --><div class="tab"><input type="radio" name="acc" id="acc1" /><label for="acc1"><h2>01</h2><h3>权限申请目的不明</h3></label><div class="content"><p>未告知申请目的。App申请系统权限时未说明权限的申请目的,例如仅通过操作系统弹窗向用户申请系统权限,未通过App额外弹窗提示或在系统弹窗中编辑目的等方式,告知用户权限申请目的。</p></div></div>
</div>

实现基础结构样式

.container {margin: 0 40px;max-width: 600px;display: flex;flex-direction: column;gap: 20px;
}.container h1 {color: #333;
}.container .tab {position: relative;background: #fff;padding: 0 20px 20px;box-shadow: 0 15px 15px rgba(0, 0, 0, 0.05);border-radius: 5px;overflow: hidden;
}

修改单选按钮样式

.container .tab input {appearance: none;
}.container .tab label {display: flex;align-items: center;cursor: pointer;
}.container .tab label::after {content: "+";position: absolute;right: 20px;font-size: 1.4em;color: rgba(0, 0, 0, 0.1);transition: transform 1s;
}.container .tab:hover label::after {color: #333;
}

编写编号样式

.container .tab label h2 {width: 40px;height: 40px;background: #333;display: flex;justify-content: center;align-items: center;color: #fff;font-size: 1.25em;border-radius: 5px;margin-right: 10px;
}

编写单选按钮激活状态下的样式

.container .tab label h3 {position: relative;font-weight: 500;color: #333;z-index: 10;
}.container .tab .content {max-height: 0;transition: 1s;overflow: hidden;
}.container .tab input:checked ~ .content {max-height: 100vh;
}

实现上述代码后,效果如下:

在这里插入图片描述

升级编号的样式

.container .tab .content p {position: relative;padding: 10px 0;color: #333;z-index: 10;line-height: 25px;
}.container .tab:nth-child(2) label h2 {background: linear-gradient(135deg, #70f570, #49c628);
}.container .tab:nth-child(3) label h2 {background: linear-gradient(135deg, #3c8ce7, #00eaff);
}.container .tab:nth-child(4) label h2 {background: linear-gradient(135deg, #ff96f9, #c32bac);
}.container .tab:nth-child(5) label h2 {background: linear-gradient(135deg, #fd6e6a, #ffc600);
}

实现激活状态下的卡片背景样式

.container .tab input:checked ~ label h2 {position: absolute;top: 0;left: 0;width: 100%;height: 100%;color: rgba(255, 255, 255, 0.2);font-size: 8em;justify-content: flex-end;padding: 20px;
}.container .tab input:checked ~ label h3 {background: #fff;padding: 4px 15px;color: #333;border-radius: 4px;box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}.container .tab input:checked ~ .content p {color: #fff;
}

完整代码下载

完整代码下载

http://www.lryc.cn/news/375704.html

相关文章:

  • Kong AI Gateway 正式 GA !
  • HTML5有哪些新特性?
  • SQL Server入门-SSMS简单使用(2008R2版)-2
  • php实现modbus CRC校验
  • 2025年计算机毕业设计题目参考
  • ERP、CRM、SRM、PLM、HRM、OA……都是啥意思?
  • Jmeter分布式、测试报告、并发数计算、插件添加方式、常用图表
  • 3D三维模型展示上传VR全景创建H5开源版开发
  • js中!emailPattern.test(email) 的test是什么意思
  • 半监督医学图像分割:基于对抗一致性学习和动态卷积网络的方法| 文献速递-深度学习结合医疗影像疾病诊断与病灶分割
  • Scikit-Learn支持向量机回归
  • ElasticSearch的桶聚合
  • vue引入aos.js实现滚动动画
  • python+selenium之点击元素报错:‘NoneType‘ object has no attribute ‘click‘
  • Web 品质国际化
  • 绿色免费离线版JS加密混淆工具 - 支持全景VR加密, 小程序js加密, H5网站加密
  • 文心一言 VS 讯飞星火 VS chatgpt (284)-- 算法导论21.2 2题
  • 计算机组成原理网课笔记2
  • C++ | Leetcode C++题解之第143题重排链表
  • 手写一个JSON可视化工具
  • 洁盟超声波清洗机怎么样?2024爆款机型声波清洗机测评、一篇看懂
  • react 自定义鼠标右键点击事件
  • make V=1 分析
  • 每天一个数据分析题(三百五十八)-图表决策树
  • HarmonyOS 页面路由(Router)
  • Python 正则表达式语法
  • 计算机专业毕设-校园二手交易平台
  • 微信小程序添加服务类目|《非经营性互联网信息服务备案核准》怎么获取
  • Internet Download Manager ( 极速下载器 ) 序列号注册码 IDM下载器注册机中文激活破解版
  • FPGA - 滤波器 - IIR滤波器设计