【问题标题】:opacity issue - also setting image不透明度问题 - 也设置图像
【发布时间】:2011-09-08 01:20:44
【问题描述】:

我的图像设置不透明度也有问题。有没有办法不设置我的图像的不透明度?

<div id="divShow" runat="server" visible="false" 
        style="opacity:0.4; filter:alpha(opacity=40); background-color:Black; width:100%; height:100%; z-index:10; top:0; left:0; position:fixed;">
   <table>

   <tr><td align="center">
       <asp:Image ID="imgShow" runat="server" ImageUrl="~/Image/Car.jpg"/>
        <asp:LinkButton ID="lnkClose" runat="server" Font-Size="8pt" 
                   Width="200px" 
           style="top: 196px; left: 60px; position: absolute; height: 16px">Close</asp:LinkButton>
   </td></tr></table></div>

【问题讨论】:

  • 重新标记为 asp.net 和 css,而不是示例中根本没有使用的 jquery。
  • 不要得到你的问题。不透明度不工作吗?或者你想要不透明度的替代品?

标签: asp.net html css


【解决方案1】:

我认为您正在寻找的是rgba()。将您的样式设置为:

#divShow {
  background: rgb(0, 0, 0); /* The Fallback */
  background: rgba(0, 0, 0, 0.4);
  -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";
  filter: alpha(opacity=40);
}

如果您希望它在所有版本的 IE 中正常工作,请在 filter 之前保留 -ms-filter

//编辑

这是您的代码,带有样式:

<div id="divShow" runat="server" visible="false" 
        style="height:100%; width:100%; z-index:10; position:fixed; top:0; left:0; background:black; background: rgba(0,0,0,0.4); -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=40)"; filter: alpha(opacity=40);">
   <table>
       <tr>
          <td align="center">
             <asp:Image ID="imgShow" runat="server" ImageUrl="~/Image/Car.jpg"/>
             <asp:LinkButton ID="lnkClose" runat="server" Font-Size="8pt" width="200px" style="top: 196px; left: 60px; position: absolute; height: 16px">
                Close
             </asp:LinkButton>
          </td>
       </tr>
   </table>
</div>

【讨论】:

  • 如果您希望背景在一定程度上透明但内容是透明的。
  • @ max,是的,我只想要背景,而不是我的图像。但这不起作用。
  • @jack,我已经用包含在实际 html 中的新 css 更新了答案。
  • 我几乎复制了你更新的内容,运行了我的项目,但我收到了一个错误...... div 标签上的“服务器标签格式不正确”。有什么建议吗?
  • 你有我可以查看的项目的链接吗?
【解决方案2】:

有没有办法不设置不透明度 我的形象?

嗯...如果你不让它不透明,不要添加 CSS 使其不透明?

【讨论】:

    猜你喜欢
    • 2010-11-09
    • 1970-01-01
    • 2021-09-09
    • 2011-09-29
    • 1970-01-01
    • 2013-01-22
    • 2015-10-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多