css - 如何风格和?
?
问题描述
刚刚发现和标签。默认给人一种很粗暴的风格。我使用::marker 伪元素成功删除了默认标记,但不知道如何将其放在右侧。使用::after 伪元素,但无法在摘要“打开”时为其设置动画(旋转 180 度或缩放)。有正确的方法吗?还是我的方法遗漏了什么?谢谢。
PS:由于我是新手,我不知道如何将Google图标字体获取到codepen。但是,您会看到我尝试使用 expand_arrow 图标做的事情。
* {
box-sizing: border-box;
margin: 0px;
padding: 0px;
}
.thing {
background-color: cadetblue;
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.new_game {
font-size: 3rem;
}
.what_is_question {
background-color: cornflowerblue;
cursor: pointer;
}
.what_is_question[open] {
background-color: darkmagenta;
}
.what_is_question {
font-size: 5rem;
}
.question_title {
position: relative;
}
.question_title::after {
content: url(./images/expand_more_black_24dp.svg);
}
.what_is_question[open] .question_title::after {
transform: rotate(180deg);
}
.question_title::marker {
content: none;
}
.answer {
background-color: darkkhaki;
font-size: 3rem;
padding-left: 3.5%;
}
<div class="thing">
<h1 class="new_game">QnA</h1>
<details class="what_is_question">
<summary class="question_title">What is the question?</summary>
<p class="answer">The question is the answer.</p>
</details>
</div>
解决方案
问题是您不能应用于transforms
带有display: inline
.
所以添加display: inline-block;
到你的.question-title
.what_is_question[open] .question_title::after {
display: inline-block;
transform: rotate(180deg);
}
推荐阅读
- android - 删除 viewpager 项目而不重新加载其他项目
- git - 如何在 svn 上,在 Windows 上,用一个裸仓库镜像 git
- javascript - d.ts 用于覆盖类方法的声明
- postgresql - 在 Travis 上构建测试失败
- mongodb - 将 Spring Boot 插件从 2.2.6.RELEASE 升级到 2.3.4.RELEASE 后,MongoDB 无法正常工作
- php - 从codeigniter中的url中删除index.php时,我收到以下错误。未找到在此服务器上找不到请求的URL
- python - 从请求响应中查找以单词开头的完整字符串
- reactjs - 使用 react-dropzone 时,如何在一个页面上有多个 dropzones 来预览多个图像?
- python-3.x - 这个python 3脚本有什么问题
- python-3.x - 根据字典列表中的值中的子字符串对字典中的值进行分组