Html.ActionLink的CSS图像

john_optional
 Html.ActionLink("", "ActionResult", new { CustomerId= DataBinder.Eval(c.DataItem, "CustomerId") }, new { target = "_blank", @style = "background-image:url(/Image/edit.png); width:50px; height:30px;" }));

你好,

我尝试为actionlink设置图片,但是它始终为空。

如何将图片设置为html.actionlink?

我希望动作链接看起来像图像(图像按钮)

注意:请不要向我提供href等。

任何帮助将不胜感激。

谢谢。

詹姆斯·唐纳利

如评论中所述,当您不提供任何文本时,由于您的元素设置为显示为,因此图像不会显示inline没有文本,您的元素就没有大小,无论元素样式中指定了什么widthheight属性。要解决此问题,请将元素设置为显示为inline-block

(Html.ActionLink(
    "",
    "ActionResult",
    new {
        CustomerId= DataBinder.Eval(c.DataItem, "CustomerId")
    },
    new {
        target = "_blank",
        @style = "
            background-image:url(/Image/edit.png);
            display:inline-block;
            width:50px;
            height:30px;
        "
    })
);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章