背景图片的eval [英] background-image eval

查看:145
本文介绍了背景图片的eval的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的DataList 来显示缩略图,我该如何使用背景图片的URL与评估

这code给我的服务器标签不规范错误。

 < ASP:DataList控件ID =DataListPortfolio=服务器RepeatColumns =3>
        <&ItemTemplate中GT;< ASP:图片ID =ImageButton1=服务器
           风格=背景图像:网址('<%#的eval(featuredImagesSmall)%>'); />        < / ItemTemplate中>
< / ASP:DataList控件>


解决方案

根据您的意见,你可能只是想用一个 DIV 而不是< ASP:图像(呈现为 IMG ),为了实现这一目标都是一样大小的图像大小,无论缩略图

 < ASP:DataList控件ID =DataListPortfolio=服务器RepeatColumns =3>
    <&ItemTemplate中GT;
        < D​​IV的风格=宽度:100像素,高度:100像素;背景位置:中心;背景图像:网址(<%#的eval(featuredImagesSmall)%>)'>< / DIV>
    < / ItemTemplate中>
< / ASP:DataList控件>

我只是把股利任意高度和宽度,但将确保所有的缩略图的大小相同。您可以使用CSS发挥到div内的图像的位置。

I am using DataList to show thumbnails, how can I use background-image url with eval

This code gives me The server tag is not well formed error.

<asp:DataList ID="DataListPortfolio" runat="server" RepeatColumns="3">
        <ItemTemplate>

<asp:Image ID="ImageButton1" runat="server" 
           style="background-image: url('<%#Eval("featuredImagesSmall")%>');" />

        </ItemTemplate>
</asp:DataList>

解决方案

According to your comments, you probably just want to use a div instead of <asp:Image (which renders as an img), in order to achieve thumbnails that are all the same size regardless of the image size:

<asp:DataList ID="DataListPortfolio" runat="server" RepeatColumns="3">
    <ItemTemplate>
        <div style='width:100px;height:100px;background-position:center;background-image:url(<%# Eval("featuredImagesSmall") %>)'></div>
    </ItemTemplate>
</asp:DataList>

I just put an arbitrary height and width on the div, but that will ensure all the thumbnails are the same size. You can play with the CSS to position the image inside the div.

这篇关于背景图片的eval的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆