gpt4 book ai didi

html - 根据表格大小调整图像大小

转载 作者:行者123 更新时间:2023-11-28 07:35:34 26 4
gpt4 key购买 nike

我想在图像上放置一个表格,但我遇到了问题。表格的内容是动态的,我需要能够使这张图片的高度适合表格的大小。

这是它的样子: My HTML page

这是我的代码:

<div style="position:relative;margin-top:20px;">
<img style="position:relative; max-height:100%;max-width:100%" src="~/Content/Images/menu13.jpg">
@using (Html.BeginForm("order", "menu", "post"))
{

<table style="position:absolute;top:102px;left:110px;color:white; font-family:'Century Gothic'; font-size:16px;" class="">

<tr>

<th style="width:150px;">Day</th>
<th style="width:150px;">Meal</th>
<th class="text-center">Normal</th>
<th style="width:100px;"></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>
@{


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

string size = "";
string type = "";
<tr>
<td style="vertical-align:top;">@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>
}
}

</table>

}

最佳答案

一个解决方案是将其分成三张图片,如下所示:

enter image description here

enter image description here

enter image description here

然后,在您的 <thead> 上使用顶部和底部作为非重复背景和 <tfoot> , 中间切片作为 <tbody> 上的重复 y 背景.

根据您的浏览器兼容性要求,您还可以将所有三个背景堆叠在一个元素上(例如顶级 <table> 元素):http://caniuse.com/#feat=multibackgrounds

关于html - 根据表格大小调整图像大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31223812/

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