HTML.Image助手方法 [英] Html.Image helper method

查看:59
本文介绍了HTML.Image助手方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HTML帮助器在MVC视图上显示图像
<%=Html.Image()%>起作用.我需要调整图像大小以适合div,但无法这样做.调整div的大小对图像没有影响.有一个重载,它接受了我认为可以使用的参数对象htmlAttribute,但是我也无法使之工作.
有谁知道尺寸来自模型的图像的方法吗?

谢谢,
Jim

I am displaying an image on a MVC View using the Html helper
<%=Html.Image()%> which works. I need to size the image to fit within the div, but am unable to do so. Sizing the div has no affect on the image. There is an overload that takes the argument object htmlAttribute that I thought I could use, but I can''t make that work either.
Does anyone know of a way to size an image that comes from the model?

Thanks,
Jim

推荐答案

您可能必须使用javascript来获取div的大小(假设已为其分配了ID),然后可以将图像缩放到适合.
You probably have to use javascript to get the size of the div (assuming it has an ID assigned to it), and then you can scale the image to fit.


这篇关于HTML.Image助手方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆