[英]How do I make a background image span across each table row and be dynamically resizable with HTML and/or CSS?
I have the following code but it makes the table appear like this when resizing.我有以下代码,但它使表格在调整大小时看起来像这样。 How can I make each row have a background image that is resized properly as the browser window is resized?
当浏览器 window 被调整大小时,如何使每一行都有一个正确调整大小的背景图像?
<style type="text/css">
.tg {border-collapse:collapse;border-spacing:0;}
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
overflow:hidden;padding:10px 5px;word-break:normal;}
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
.tg .tg-0lax{text-align:left;vertical-align:top}
table {
width: 600px;
background-image: url('bg.png');
background-repeat: repeat-y;
background-size: 100%;
height: 100%;
}
}
</style>
<table class="tg">
<tr>
<td class="tg-0lax">Check</td>
<td class="tg-0lax">MB Image</td>
<td class="tg-0lax">LE 1000</td>
<td class="tg-0lax">MB Name<p />Release</td>
</tr>
<tr>
<td class="tg-0lax">Check</td>
<td class="tg-0lax">MB Image</td>
<td class="tg-0lax">LE 1000</td>
<td class="tg-0lax">MB Name<p />Release</td>
</tr>
<tr>
<td class="tg-0lax">Check</td>
<td class="tg-0lax">MB Image</td>
<td class="tg-0lax">LE 1000</td>
<td class="tg-0lax">MB Name<p />Release</td>
</tr>
<tr>
<td class="tg-0lax">Check</td>
<td class="tg-0lax">MB Image</td>
<td class="tg-0lax">LE 1000</td>
<td class="tg-0lax">MB Name<p />Release</td>
</tr>
</table>
I want each row to use this image:我希望每一行都使用这个图像:
and look like this and be resizable:看起来像这样并且可以调整大小:
background-size?背景大小? or is that not what you expected?
或者这不是你所期望的? If not clarify the expected result.
如果不澄清预期的结果。
body{margin:0;} table { height: 100vh; width: 100vw; border-collapse: collapse } td { border: solid 1px } tr { background: url(https://i.stack.imgur.com/1aeFs.png) -6vw 0; background-size: 106% 100%; }
<table> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.