html - CSS 不工作任何人都可以调试我的代码吗?
问题描述
好的,这就是我的问题:我有一个父母 div
和h2
一个,当我从我的 cssp
中删除包装时,我的 css 工作正常,但是一旦我再次添加我的元素就停止工作div
h2
p
div
Top:;
p
这是我的代码:
#p3 {
position: relative;
top: 5%;
left: 5%;
font-weight: 500;
font-size: 15px;
max-width: 39%;
}
<div>
<h2 id="identities">Identities</h2>
<p id="p3">One may identify as non-binary on its own or they may identify as a gender that falls in the category of non-binary.<br><br> Any gender that is not strictly and completely male or strictly and completely female falls under the category of non-binary.<br><br> Some common non-binary identities include:
</p>
</div>
这是没有div
父母的情况:
这就是我添加div
父级时发生的情况:
解决方案
我认为您需要p3
更好地定位元素。试试这段代码
css
div > #p3 {
position: relative;
top: 5%;
left: 5%;
font-weight: 500;
font-size: 15px;
max-width: 39%;
}
html
<div>
<h2 id="identities">Identities</h2>
<p id="p3">One may identify as non-binary on its own or they may identify as a gender that falls in the category of non-binary.<br><br> Any gender that is not strictly and completely male or strictly and completely female falls under the category of non-binary.<br><br> Some common non-binary identities include:
</p>
</div>
推荐阅读
- python - 将大型列表存储在 Dynamo DB 表中以优化解码时间的最佳方式
- python - 将“列表列表”Wiki 页面组织成表格
- arduino - 如何计算三轴加速度计的旋转角度?
- mysql - 如何获取技能='Python'和技能='Javascript'的uid记录
- java - 对象列表中的列总和
- python - 禁用 Django 自动分配未保存对象的反向关系
- java - 从字符列表中创建字符串然后清除它的最有效方法
- r - R 在函数内绘制箱线图无法正确显示 y 数据
- javascript - React.createElement:类型无效——需要一个字符串——index.js
- python - 我可以通过烧瓶请求获取 URL 参数(在 url 规则中设置)吗?