C# 设置包含动态添加图像的div的高度和宽度
如何将div的高度和宽度设置为其中包含的图像的高度和宽度?图像是动态提供的,div的高度和宽度随图像不断变化 确保div设置为C# 设置包含动态添加图像的div的高度和宽度,c#,html,C#,Html,如何将div的高度和宽度设置为其中包含的图像的高度和宽度?图像是动态提供的,div的高度和宽度随图像不断变化 确保div设置为runat=“server”,并为div提供一个id属性 然后在你的C代码里 divID.Attributes.Add("height", heightValue) <div runat="server" id="div1"></div> div1.Style["width"] = image.Width + ""; div1.Style["h
runat=“server”
,并为div提供一个id属性
然后在你的C代码里
divID.Attributes.Add("height", heightValue)
<div runat="server" id="div1"></div>
div1.Style["width"] = image.Width + "";
div1.Style["height"] = image.Height + "";