欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 锐评 > 使用CSS常见问题解答卡片

使用CSS常见问题解答卡片

2025/2/22 2:11:05 来源:https://blog.csdn.net/qq_33003143/article/details/139702542  浏览:    关键词:使用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;
}

完整代码下载

完整代码下载

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词