简体   繁体   English

如何在文本字段中使用图像设置HTML表单的半透明背景

[英]How to set semi transparent background of HTML form with images in text fields

Hi I want to create a simple HTML form with a semi transparent background also I want to set an image on the left in text field(input field). 嗨,我想创建一个具有semi transparent background的简单HTML表单,我也想在文本字段(输入字段)的左侧设置一个图像。

Here is the example where I saw that form: 这是我看到该表格的示例:

Demo Of my requirement 演示我的要求

In this form there is icon on the left hand side in each input type and also the form is semi transparent. 在此表单中,每种输入类型的左侧都有一个图标,并且该表单是semi transparent.

Is there any way to do so either by css or html ? 有没有办法通过csshtml做到这一点?

please Help me.. Thanks in advance. 请帮助我..在此先感谢。

You can do that with CSS 您可以使用CSS做到这一点

<div class="form-container">
<form>
<input type="text" name="" value="">
</form>
</div>

Css File : CSS文件:

input {
    background-image:url('mon-image.png');
}

.form-container{
     background-color:rgba(255,255,255,0.8); 
}

You can also create a white semi transparent PNG file of 32x32 px and use it as background image and repeat it on X and Y 您还可以创建32x32 px的白色半透明PNG文件,并将其用作背景图像,并在X和Y上重复

.form-container{
     background-image:url('my-transparent-png.png');
     background-repeat:  repeat ; 
}

This last method works with most of web browsers. 后一种方法适用于大多数Web浏览器。

In CSS you can do: 在CSS中,您可以执行以下操作:

background-color: rbga(255, 255, 255, 0.5);

You can read more about it at https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#rgba() 您可以在https://developer.mozilla.org/zh-CN/docs/Web/CSS/color_value#rgba()上了解有关此内容的更多信息。

You can provide opacity for these images to look semi transparent via CSS 您可以提供opacity为这些图像看起来semi transparent通过CSS

Example

img
{
 opacity:.6;
}

CSS的最简单方法是

opacity: 0.5;

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

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