问题描述
我正在尝试使用其后续兄弟姐妹的类名在 CSS 中选择前一个兄弟姐妹,但我正在努力弄清楚。我的目标是通过 bottom-margin
类
title
元素中删除 h1-no-margin
body,html,h1 {
margin: 0;
padding: 0;
}
.container {
width: 100%;
height: 200px;
}
.container h1.title {
margin-bottom: 2.5rem;
}
<!-- I cannot edit the HTML for the container class -->
<div class="container">
<!-- I cannot edit the HTML for the title class-->
<h1 class="title">This is a title</h1>
<!-- I can edit the HTML for the below div,so I can add and remove classes on it -->
<div class="info h1-no-margin"></div>
</div>
.
注意事项:
- 我无法访问任何 JavaScript
- 我无权访问 HTML 的某些部分
- 我在 SO 上提出的其他解决方案上没有取得任何成功
这是 HTML:
<!-- I cannot edit the HTML for the container class -->
<div class="container">
<!-- I cannot edit the HTML for the title class-->
<h1 class="title">This is a title</h1>
<!-- I can edit the HTML for the below div,so I can add and remove classes on it -->
<div class="info h1-no-margin"></div>
</div>
这是CSS:
body,h1 {
margin: 0;
padding: 0;
}
.container {
width: 100%;
height: 200px;
}
.container h1.title {
margin-bottom: 2.5rem;
}
这背后的想法是我可以使用 div 上的 h1-no-margin
类和 info
类来添加和删除不同页面上的边距。
任何帮助将不胜感激,谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)