我怎样才能看到html中的inpute文本中的背景图像?

时间:2017-02-15 08:40:26

标签: html css

我尝试以HTML格式编写网站,我需要在输入文本后面查看我的背景图片,例如搜索。 我能做什么? 我尝试设置图像背景但是当我添加输入文本时它是白色的,我无法看到背后的bg图像 Something like this

<html>
 <head>
  <style>
    body {
    background-image: url(example url}#weap{display:inline;}

  </style>
 </head>
 <body>
  <div id="wrap">
   <input id="search" name="search" type="text" placeholder="What're we looking for ?">
  </div>
 </body>
</html>

4 个答案:

答案 0 :(得分:3)

您可以将opacity添加到搜索字段中。例如:

#search{
  opacity: .7;
  filter: alpha(opacity=70); /* For IE8 and earlier */
}

答案 1 :(得分:0)

尝试使用这样的样式:

input {
   opacity: 0.3;
}

答案 2 :(得分:0)

Reduce opacity of input field, so that the background image will get visible through the input field,
in your case use below code

#search{
   opacity:0.5;
   outline: none;
   webkit-appearance: none;
}

Here is the reference for learning more about Opacity attribute:
[link]:https://www.w3schools.com/cssref/css3_pr_opacity.asp

答案 3 :(得分:0)

#search{
position: relative;
z-index: 999999;
opacity: 0.3;
}