Css 如何防止h2含量侵入:在含量之前?
是的,我对我的:before图标有点问题 我想要的是h2内容在水平线上,而不是在:before内容下的换行之后Css 如何防止h2含量侵入:在含量之前?,css,Css,是的,我对我的:before图标有点问题 我想要的是h2内容在水平线上,而不是在:before内容下的换行之后 有什么建议吗?使用位置:绝对;左:0用于图标,并将图标大小添加到h2。注意:不要忘记将h2的位置设置为相对 示例: h2{ position: relative; padding-left: 60px; /* the size of your icon plus a spacer */ } h2:before{ content:''; position:
有什么建议吗?使用
位置:绝对;左:0
用于图标,并将图标大小添加到h2。注意:不要忘记将h2的位置设置为相对
示例:
h2{
position: relative;
padding-left: 60px; /* the size of your icon plus a spacer */
}
h2:before{
content:'';
position:absolute;
left:0;
height: 50px; /* height of your icon */
width:50px; /* width of your icon */
background-image:url(img/icon.png); /* your icon */
}
您可以尝试将图标完全从流中移除。您需要调整
顶部
和左侧
值
h2 {
position: relative
}
h2:before {
position: absolute,
top: 0;
left: -20px;
}
你能发送当前代码吗?您可能已将显示设置为:before to block?谢谢各位您救了我一天:)