我在一个网站上找到了这个,它可以很好地满足我的需要。这不是完整的代码,但我只需要知道如何在 VB 代码中更改 pic-1、pic-2 等的背景图像。我在这里尝试的方法不起作用...
pic-1.Style.Add("background-image", "file/images/food/burger.jpg")
我收到“图片”未声明。
前端..
<div class="pic-wrapper">
<figure class="pic-1" runat="server"></figure>
<figure class="pic-2" runat="server"></figure>
<figure class="pic-3" runat="server"></figure>
<figure class="pic-4" runat="server"></figure>
</div>
CSS...
figure {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
/*animation*/
animation: slideShow 24s linear infinite 0s;
-o-animation: slideShow 24s linear infinite 0s;
-moz-animation: slideShow 24s linear infinite 0s;
-webkit-animation: slideShow 24s linear infinite 0s;
}
.pic-1 {
opacity: 1;
background: url(images/slider-cocktails.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
VB.Net..
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
pic-1.Style.Add("background-image", "file/images/food/burger.jpg")
End Sub