Reputation: 1697
Consider the following Razor view - Let's call it VIEW-1 :
<h2>Index</h2>
@if (true)
{
<img src="/Content/images/black_square.png" alt="Black Square" />
}
<img src="/Content/images/black_square.png" alt="Black Square" />
When I load the VIEW-1 into Internet Explorer 8 or Mozilla Firefox 9.0.1 the two "black square" images are separated by a space.
But I do not want the two images separated.
Now consider the following Razor view - Let's call it VIEW-2 :
<h2>Index</h2>
<img src="/Content/images/black_square.png" alt="Black Square" /><img src="/Content/images/black_square.png" alt="Black Square" />
When I load the VIEW-1 in Internet Explorer 8 or Mozilla Firefox 9.0.1 the two "black square" images are not separated by a space.
VIEW-1 and VIEW-2 are example views.
The "separated images" fact is a little problem in one of my ASP .NET MVC 3 project.
I can not write all my image elements on one line because some of them depend on condition statements and loop statements.
Is there a way to get image elements not separated by a space even if they are not written on the same line ?
Upvotes: 1
Views: 1529
Reputation: 23511
Surprisingly, Razor lets you do this:
<h2>Index</h2>
@if (true)
{
<img src="/Content/images/black_square.png" alt="Black Square" />}<img src="/Content/images/black_square.png" alt="Black Square" />
... though whenever I do, I add an apologetic comment nearby explaining why I've done it.
Upvotes: 1
Reputation: 1560
You can solve this by inserting the images into a 1 row and 1 cell table:
<table>
@if (true)
{
<img src="/Content/images/black_square.png" alt="Black Square" />
}
<img src="/Content/images/black_square.png" alt="Black Square" />
</table>
Upvotes: -1
Reputation: 1038710
You could try using CSS:
<div class="pictures">
@if (true)
{
<img src="/Content/images/black_square.png" alt="Black Square" />
}
<img src="/Content/images/black_square.png" alt="Black Square" />
</div>
and then:
.pictures img {
float: left;
}
Upvotes: 1