简体   繁体   English

更改背景的不透明度,而不是子元素

[英]Change the opacity of the background, not the child elements

Is it possible to change the opacity of the background image of the form but not the fields inside the form. 是否可以更改窗体背景图像的不透明度,而不是窗体内的字段。 CSS: CSS:

#myForm{
  background-image:url("images/Binary.jpg");      
  border:1px solid #080808;
  box-shadow:#444444 0 0 1px inset;
  margin:20px auto 20px 52%;
  padding:20px;
  width:484px;
  -moz-box-shadow:black 4px 5px 11px;
  -webkit-box-shadow:black 4px 5px 11px;
  box-shadow:black 4px 5px 11px;
}

So, this is my CSS and I want to reduce the opacity of the Binary.jpg only not the contents of the form. 所以,这是我的CSS,我想减少Binary.jpg的不透明度,而不是表单的内容。 Is it possible?? 可能吗??

Put simply: no. 简单地说:不。 You would need to make the image a semi-transparent PNG. 您需要将图像设置为半透明PNG。

you can do this by with less opacity image change background on hover with less opecativy gif or png image 你可以通过较少的不透明图像更改背景悬停与较少的oifativy gif或png图像来做到这一点

or try something like might work 或尝试类似的工作

<div id="myForm">
    <form>...</form>
</div>  

css CSS

div {
 -khtml-opacity:.50; 
 -moz-opacity:.50; 
 -ms-filter:"alpha(opacity=50)";
  filter:alpha(opacity=50);
  filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0.5);
  opacity:.50; 
}

Well I've hacked it, so certainly you can do it like this if you want 好吧,我已经黑了它,所以如果你愿意,你当然可以这样做

Demo 演示

HTML HTML

<div class="wrapper">
    <div class="holder">This is awesome yea ;)</div>
</div>

CSS CSS

.wrapper {  
    position: relative;
    color: #fff;
}

.wrapper:before {
    content: "";
    position: absolute;
    z-index: 1;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background-image: url('http://www.freegreatpicture.com/files/146/25234-colorful-high-resolution-background.jpg');
    opacity: 0.7;
}

.holder {
    z-index: 2;
    position: relative;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM