gpt4 book ai didi

c# - 将表格置于图像之上

转载 作者:太空宇宙 更新时间:2023-11-04 11:41:10 24 4
gpt4 key购买 nike

我有一个表格,我想将其放在图像上,问题是表格内容是动态的,因此图像大小需要根据表格的大小缩小或增大,实现此目的的最佳方法是什么.

这是图像:http://postimg.org/image/s2vjf4p3t/

这是我的表格的 html

    <table id="menutable">

<thead>
<tr>
<th style="width:100px;">Day</th>
<th style="width:150px;">Meal</th>
<th class="text-center">Normal</th>
<th style="width:20px;"></th>
<th class="text-center">No carb</th>

</tr>

<tr>
<th></th>
<th></th>
<th style="width:240px;" class="text-center">
<div class="row">
<div class="col-md-4">
Kiddies
</div>
<div class="col-md-4">
Standard
</div>
<div class="col-md-4">
Large
</div>
</div>
</th>

<th></th>

<th style="width:240px;" class="text-center">
<div class="row">
<div class="col-md-4">
Kiddies
</div>
<div class="col-md-4">
Standard
</div>
<div class="col-md-4">
Large
</div>
</div>
</th>
</tr>
</thead>

<tbody>

@{


for (int i = 0; i < 5; i++)//foreach day in the week
{

string size = "";
string type = "";
<tr>
<td style="vertical-align:top; font-size:20px;">@Model.Menu[i].Day</td>

<td>
<b>@Model.Menu[i].NormalMeal</b>
<br />
<p>@Model.Menu[i].Description</p>
<p><b>@Model.Menu[i].LowMeal</b></p>
</td>

@for (int p = 0; p < 2; p++) //for normal and nocarb
{
if (p == 0)
{
type = "normal";
}
else
{
type = "nocarb";
}
if (p == 1)
{
<td></td>
}
<td class="text-center">

<div class="row">
@for (int j = 0; j < 3; j++) //the sizes
{
if (j == 0)
{
size = "kid";
}
else if (j == 1)
{
size = "standard";
}
else
{
size = "large";
}
<div class="col-md-4">
<select style="position:relative;top:0px; font-size:12px;" name="@(Model.Menu[i].Day.ToLower().ToString() + "_"+type+"_" + size)" @if (i <= disabledDays) { @disabled }>
<option> </option>
@for (int k = 1; k <= 10; k++)
{
<option>@k</option>
}
</select>
</div>
}

</div>
</td>
}


</tr>
<tr>
<td colspan="6">
<hr />
</td>
</tr>
}
}
</tbody>

<tfoot>

</tfoot>

</table>

最佳答案

这里需要做的是将表格和图片放在同一个容器中。使图像绝对化,这样容器的大小由表格决定,而图像也应该有 100% 的宽度和高度来填充它。

您的代码应如下所示:

  <div style="position:relative">
<img src="" style="position: absolute; width: 100%; height: 100%" />
<table>
...
</table>

</div>

关于c# - 将表格置于图像之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31323556/

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