Html 如何设置某个绝对位置div的背景色?
我有一个html代码:Html 如何设置某个绝对位置div的背景色?,html,css,Html,Css,我有一个html代码: <b> <div class="p" id="p4" style="top:77.0pt;left:179.91301pt;font-family:Times;font-size:13.0pt;">Can</div> <div class="p" id="p5" style="top:77.0pt;left:212.02301pt;font-family:Times;font-size:
<b>
<div class="p" id="p4" style="top:77.0pt;left:179.91301pt;font-family:Times;font-size:13.0pt;">Can</div>
<div class="p" id="p5" style="top:77.0pt;left:212.02301pt;font-family:Times;font-size:13.0pt;">you</div>
<div class="p" id="p6" style="top:77.0pt;left:240.53201pt;font-family:Times;font-size:13.0pt;">help</div>
<div class="p" id="p7" style="top:77.0pt;left:266.14203pt;font-family:Times;font-size:13.0pt;">me?</div>
</b>
我想为标签设置背景色!我该怎么做呢?您可以在样式表中设置样式
b {
display:block;
background-color: #f00;
}
如果你不想让所有标签都有一个红色的背景,你可以给它一个特定的类或id
因为它是绝对定位的,所以您还需要定义宽度和高度。简单:
b{
background-color: /*color here*/;
}
如果您希望以内联方式执行此操作,其工作方式与您为其他用户执行此操作的方式相同:
<b style="background-color: /*color here*/;">
内联:
<b style="display: inline-block; background-color: /*color*/;">
这样做只会设置文本的背景:
或者,您可以让它填充文本填充区域的整个背景
要做到这一点,只需在块之间更改内联块
主题外-请避免使用内联样式。。。没有任何位置,则块div不能在内联b中。最后,绝对定位元素的高度为零。对不起!我有一些错误!我编辑了我的帖子只是一个旁注,我不认为使用inside在语义上是正确的。谢谢但我想让p班排队@用户3651839只需定义:.p{display:inline;}或您。这是一个@user3651839您忘记了开头标记:如果您添加了它。
<b style="display: inline-block; background-color: /*color*/;">