我需要向sitefinity画廊中的每个图像添加字幕。我尝试将每个图像放入div并以这种方式进行分组,但这完全弄乱了画廊的格式。我也尝试过使用跨度,因此我只能使用不太灵敏的CSS来定位文本。
@for (int i = 0; i < Model.Items.Count(); i++)
{
var item = Model.Items.ElementAt(i);
var thumbnailViewModel = (ThumbnailViewModel)item;
var itemIndex = (Model.CurrentPage - 1) * ViewBag.ItemsPerPage + i + 1;
var detailPageUrl = ViewBag.OpenInSamePage ? HyperLinkHelpers.GetDetailPageUrl(item, ViewBag.DetailsPageId, ViewBag.OpenInSamePage, Model.UrlKeyPrefix, itemIndex) :
HyperLinkHelpers.GetDetailPageUrl(item, ViewBag.DetailsPageId, ViewBag.OpenInSamePage, Model.UrlKeyPrefix);
<a class="text-center"
href="@detailPageUrl"
title="@(string.IsNullOrEmpty(item.Fields.Description) ? item.Fields.Title : item.Fields.Description)">
<img class="gallery_images" src="@(thumbnailViewModel.ThumbnailUrl)" alt='@System.Text.RegularExpressions.Regex.Replace(item.Fields.AlternativeText, @"[^\w\d_-]", "")'
@Html.GetWidthAttributeIfExists(thumbnailViewModel.Width)
@Html.GetHeightAttributeIfExists(thumbnailViewModel.Height) />
</a>
}
这是实际填充图库的代码。如何为每个图像添加字幕,并将其保留在图像下方以及图像中? 每个图像应如下所示:https://i.imgur.com/42pqS0L.png