【问题标题】:Transparent GridView in ASP .Net?ASP .Net 中的透明 GridView?
【发布时间】:2011-12-12 00:11:27
【问题描述】:

我想知道是否有任何方法可以使GridView 透明。 我知道边框可以透明,我知道该怎么做,

但是图像中的区域 12单元格的背景标题 是我关心的. 我更喜欢保留我的原始背景图像,所以我更喜欢透明度。但如果这是不行的话 我猜我也可以接受添加背景图片。

提前感谢。

【问题讨论】:

    标签: asp.net .net gridview transparency


    【解决方案1】:

    看起来您正在使用 GridView 的内置样式。例如,您的 gridview 可能类似于:

    <asp:GridView runat="server" ID="GridView1" BackColor="#DEBA84" BorderColor="#DEBA84" 
        BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2">
        <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
        <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
        <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
        <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
        <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#FFF1D4" />
        <SortedAscendingHeaderStyle BackColor="#B95C30" />
        <SortedDescendingCellStyle BackColor="#F1E5CE" />
        <SortedDescendingHeaderStyle BackColor="#93451F" />
    </asp:GridView>
    

    如果是这种情况,只需像这样删除所有样式:

    <asp:GridView runat="server" ID="GridView1">
    </asp:GridView>
    

    或者,您可以使用 CSS 和 !important 属性覆盖 Gridview 的内联样式(您需要相应地更新 CSS):

    <style type="text/css">
        table {background:transparent !important;}
        table tr {background:transparent !important;}
    </style>
    

    【讨论】:

      【解决方案2】:

      创建一个透明的小图像。 然后使用 css 将其添加到表格中:

          table
          {
              background-image: Transparent5by5.gif;
          }
      

      【讨论】:

        猜你喜欢
        • 2018-04-02
        • 2011-07-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多