开发者

Spaces between images @Html.Image

I have two images like so. (granted that the code is indented)

@Html.Image("/Images/icons/arrow-up.gif", "up")
@Html.Image("/Images/icons/arrow-down.gif", "up")

The images have a space between them.

I instead have to write as a sigle line to avoid a gap between the images, which i find not very开发者_StackOverflow readable:

@Html.Image("/Images/icons/arrow-up.gif", "up")@Html.Image("/Images/icons/arrow-down.gif", "up")

How can I fix this? thanks

Additional: Here are the two cases as printscreens

Case 1:

Spaces between images @Html.Image

Spaces between images @Html.Image

Case 2:

Spaces between images @Html.Image

Spaces between images @Html.Image


So far the best solution seems to be this.

@{
    @Html.Image("/Id/Images/icons/arrow-up.gif", "up")  
    @Html.Image("/Id/Images/icons/arrow-down.gif", "up")
}


How can I fix this?

This doesn't require any fixing. No browser cares whether there's a space or not between your HTML tags. You could of course write a custom helper that will output the two images at once:

@Html.MyImages("/Images/icons/arrow-up.gif", "/Images/icons/arrow-down.gif")

but IMHO that would be useless work.

Maybe the space you are talking about comes from some CSS rule on the containing element? Maybe setting a 0 padding and margin would remove it?


Personaly and i am not saying you should use this solution but try:

ul#Test li {float:left;list-style-type:none;}
ul#Test li img {border:none; padding:0; margin:0}

Then with some css:

<ul id="Test">
    <li>@Html.Image("/Images/icons/arrow-up.gif", "up")</li>
    <li>@Html.Image("/Images/icons/arrow-down.gif", "up")</li>
</ul>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜