是否可以为表单中的文本字段提供背景颜色?

问题描述 投票:-1回答:4

我不想将颜色设置为输入字段;我希望将背景颜色设置为文本字段。请参阅附图。就像前两个字段中的黑色背景一样,我想只为前两个带有背景颜色的字段着色。完整的表格可以给出背景颜色,这不是我想要的;我希望表单除了前两个字段外都是白色的。

html css html5 css3
4个回答
2
投票

正如我从你的图像中可以理解的那样。你需要给fieldset,前两个字段应该在<div>标签下,然后你可以设置style="background-color:black;"

例如:

<form action="demo_form.asp" style="color:green;">
    <fieldset><legend> Personal Details </legend>
    <div style="background-color:black">
First Name: <br>
<input type="text" name="fname" placeholder="Enter First Name"><br>
Last Name: <br>
<input type="text" name="lname" placeholder="Enter Last Name">
    </div>
Date Of Birth: <br>
    <input type="text" name="dob" placeholder="mm / dd / yy"><br>
        </fieldset>
</form> 

JSFiddel我希望它满足你的要求。如果是,那么就投票给这个ans。


1
投票

您可以使用宽度为100%的自定义div / class;在前两个文本框后面。

HTML:

<form>

<div class="colored">
............
first two text-boxes
...........
</div>

................
rest all text-box/form
...............

<form>

CSS:

.colored{
float:left;
background-color-#000;
width:100%;
}

我希望这能帮到您。


0
投票

用这个..

input, input[type="text"]{
background-color:#000;
}

-1
投票

你的意思是......

 input{
    border:1px solid #ddd !important;
    background-color:transparent;
    background-color:#000;
    cursor:pointer;
    color:#fff;
    padding:10px;
  }

http://jsfiddle.net/kisspa/LFLkp/

© www.soinside.com 2019 - 2024. All rights reserved.