How to add a class attribute to sitecore MVC image field

南楼画角 提交于 2019-12-25 05:24:35

问题


Using Sitecore mvc field render

@Html.Sitecore().Field("FieldName", ContentItem)

I would like to add class to image tag like below,

<img src="/images/Sample.jpg" class="hidden-xs">

So, How can I add the css class in Site core MVC image field.

Thanks in advance.


回答1:


You can simply use this one.

@Html.Sitecore().Field("FieldName", Model.PageItem, new { @class="large-image", @mw="250" })


来源:https://stackoverflow.com/questions/36092433/how-to-add-a-class-attribute-to-sitecore-mvc-image-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!