<div data-src =“中的图像”=“=”“显示=”“in =”“mvc =”“4 =”“

时间:2015-12-14 09:56:14

标签: html5 asp.net-mvc-4 razor views

=”“

我在Microsoft visual studio 2012中使用带有mvc-4的asp.net 页面有一个图像滑块
Index.cshtml如下:

<div class="camera-wrapper">
<div id="camera" class="camera-wrap">

    <div data-src="~/Images/index_slide01.jpg">
        <div class="fadeIn camera_caption">
            <h2 class="text_1 color_1">Solutions that you need!</h2>
            <a class="btn_1" href="#">More info</a>
        </div>
    </div>
    <div data-src="~/images/index_slide02.jpg">
        <div class="fadeIn camera_caption">
            <h2 class="text_1 color_1">Lorem ipsum dolor sit!</h2>
            <a class="btn_1" href="#">More info</a>
        </div>
    </div>
    <div data-src="~/images/index_slide03.jpg">
        <div class="fadeIn camera_caption">
            <h2 class="text_1 color_1">Lorem ipsum dolor sit amet, consectetur!</h2>
            <a class="btn_1" href="#">More info</a>
        </div>
    </div>

</div>

如您所见,运行应用程序时未显示图像,而使用

<img src="images/logo.png"> is working normally .    

如何让图像显示在

 <div data-src >

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

&#39;〜&#39;如果没有@Url.Content,则无法使用。请更改您的代码,如下所示。

<div class="camera-wrapper">
<div id="camera" class="camera-wrap">

    <div data-src="@Url.Content("~/Images/index_slide01.jpg")">
        <div class="fadeIn camera_caption">
            <h2 class="text_1 color_1">Solutions that you need!</h2>
            <a class="btn_1" href="#">More info</a>
        </div>
    </div>
    <div data-src="@Url.Content("~/images/index_slide02.jpg")">
        <div class="fadeIn camera_caption">
            <h2 class="text_1 color_1">Lorem ipsum dolor sit!</h2>
            <a class="btn_1" href="#">More info</a>
        </div>
    </div>
    <div data-src="@Url.Content("~/images/index_slide03.jpg")">
        <div class="fadeIn camera_caption">
            <h2 class="text_1 color_1">Lorem ipsum dolor sit amet, consectetur!</h2>
            <a class="btn_1" href="#">More info</a>
        </div>
    </div>

</div>