javascript - 当您在Javascript中单击V形时,如何将V形从指向右变为指向下?
问题描述
我从 https://fontawesome.com/icons/chevron-down 获取 chevron-down 图标,从https://fontawesome.com/icons/chevron-right获取chevron-right 图标。我不确定从哪里开始制作,这样当您单击 SHOW LESS 文本时,它将变为 SHOW MORE 并且 V 形将变为 V 形右。
另外,当您单击内容时,如何使内容也显示在 SHOW LESS 下方?
解决方案
使用 HTML5details
元素,它
- 是这里语义正确的元素,
- 不需要任何Javascript,
- 作为 HTML 标准的一部分,与屏幕阅读器兼容,
- 甚至不需要很棒的字体,因为它已经带有一个 V 字形,可以完全满足您的要求。
.restyled summary { text-transform: uppercase; }
.restyled summary::marker { content: "› "; }
.restyled summary::-webkit-details-marker { content: "› "; }
<details>
<summary>Show more</summary>
<p>More info about the details.</p>
</details>
<details class="restyled">
<summary>Show more</summary>
<p>More info about the details.</p>
</details>
https://developer.mozilla.org/de/docs/Web/HTML/Element/details
推荐阅读
- javascript - 如何从兄弟对象数组和过滤器元素创建父子对象?
- rest - 4xx/5xx 响应的 REST API 详细级别
- windows - Windows 防火墙和 %USERPROFILE% 变量
- angular - Ionic6 + Angular9中POST方法的CORS源请求错误
- record - 是什么让 RecordIO 有吸引力
- python-3.x - Pandas DataFrame 删除具有特定字符的字符串
- tensorflow - Tensorflow 看到的 GPU,但只使用 xla_cpu 并在被告知使用 xla_gpu 时崩溃
- elasticsearch - 在 AWS ElasticSearch 中搜索字段
- python - 如何从pymc3绘制概率分布?
- java - 用于 Spring Boot 项目的 buildspec.yml 文件