gpt4 book ai didi

css - 表格标题中的 bg 图片定位

转载 作者:太空宇宙 更新时间:2023-11-03 18:43:22 24 4
gpt4 key购买 nike

如何使用 css 实现以下效果(背景颜色与与标题行重叠的背景图像): enter image description here

这是表中 TH 单元格的部分。TH 行的颜色为 #0098da,TH 单元格的末尾是图像(图像的 url 在这里 http://tax.allfaces.lv/templates/tax/images/pg_arrow.png )。

我曾尝试在 TH 中定位带有 bg 图像的 div,但我遇到了图像应该与 TH 边界重叠的问题。结果我得到了以下内容:

enter image description here

HTML:

    <table id="duration-of-refund" border="0">
<tbody>
<tr>
<th>
<p>Purchases in Webshops</p>
<div class="img-at">&nbsp;</div>
</th>
<th>
<p>Currency conversion, Refund transfer</p>
<div class="img-arrow">&nbsp;</div>
</th>
</tr>
<tr>
<td>
<p>Some text here Some text here Some text here Some text here Some text here</p>
</td>
<td>
<p>Some text here Some text here Some text here Some text here Some text here</p>
</td>
</tr>
</tbody>
</table>

CSS:

    #duration-of-refund td {
width: 400px;
}
#duration-of-refund th {
font-size: 21px;
color: white;
text-align: left;
height: 84px;
max-height: 84px;
}
#duration-of-refund tr th:nth-child(1) {
background-color: #0098da;
}
#duration-of-refund tr th:nth-child(2) {
background-color: #1F5CA9;
}
#duration-of-refund tr th:nth-child(1) p, #duration-of-refund tr th:nth-child(2) p {
width: 190px;
float: left;
}
.img-at, .img-arrow {
width: 83px;
height: 84px;
float: right;
margin-right: 20px;
position: relative;
top: -20px;
}
.img-arrow {
background-image: url(http://tax.allfaces.lv/templates/tax/images/pg_arrow.png);
}
.img-at {
background-image: url(http://tax.allfaces.lv/templates/tax/images/pg_at.png);
}
#duration-of-refund tr td:nth-child(2) {
background-color: #cceaf8;
}
}

JSfiddle 示例:http://jsfiddle.net/rAVqx/

我认为,应该有另一种方法来做到这一点。

请给我一些线索如何实现这一目标?我还有其他具有不同图像的 TH 单元以相同的方式定位。

最佳答案

试试这个将图像类标签放在另一个 div 中并将样式应用为

 float:right;margin-right:90px

图像的绝对位置

 position: absolute;

你的代码刚刚被修改

HTML

<table id="duration-of-refund" border="0">
<tbody>
<tr>
<th>
<p>Purchases in Webshops</p>
<div style="float:right;margin-right:90px;">
<div class="img-at">&nbsp;</div>
</div>
</th>
<th>
<p>Currency conversion, Refund transfer</p>
<div style="float:right;margin-right:90px;">
<div class="img-arrow">&nbsp;</div>
</div>
</th>
</tr>
<tr>
<td>
<p>Some text here Some text here Some text here Some text here Some text here</p>
</td>
<td>
<p>Some text here Some text here Some text here Some text here Some text here</p>
</td>
</tr>
</tbody>
</table>

CSS:

#duration-of-refund td {
width: 400px;
}
#duration-of-refund th {
font-size: 21px;
color: white;
text-align: left;
height: 84px;
max-height: 84px;
}
#duration-of-refund tr th:nth-child(1) {
background-color: #0098da;
}
#duration-of-refund tr th:nth-child(2) {
background-color: #1F5CA9;
}
#duration-of-refund tr th:nth-child(1) p, #duration-of-refund tr th:nth-child(2) p {
width: 190px;
float: left;
}
.img-at, .img-arrow {
width: 83px;
height: 84px;
float: right;
margin-right: 20px;
position: absolute;
top: -20px;
}
.img-arrow {
background-image: url(http://tax.allfaces.lv/templates/tax/images/pg_arrow.png);
}
.img-at {
background-image: url(http://tax.allfaces.lv/templates/tax/images/pg_at.png);
}
#duration-of-refund tr td:nth-child(2) {
background-color: #cceaf8;
}
}

关于css - 表格标题中的 bg 图片定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17019547/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com