开发者

How can I apply CSS to an HTML text input?

开发者 https://www.devze.com 2023-01-09 19:39 出处:网络
Here is the ASP.Net MVC2 code that I use to display a textbox input. <div id=\"blackbar\"> <p>Sistema de Evaluaciones de Docentes</p>

Here is the ASP.Net MVC2 code that I use to display a textbox input.

<div id="blackbar">
    <p>Sistema de Evaluaciones de Docentes</p>
    <%: Html.TextBox("termino","") %>
    <img src="../../Content/search.png" alt="search" />
</div>

Here is how it renders:

<div id="blackbar">
    <p>Sistema de Evaluaciones de Docentes</p>
    <input id="termino" name="termino" type="开发者_C百科text" value="" />
    <img src="../../Content/search.png" alt="search" />
</div>

How would I use CSS for example to give the textbox a red border? How can I tell MVC2 to give this text input a class or something?

EDIT: I've tried the following, but the text I write into the input isn't green.

.textinput
{
    color:Green;
}

<%: Html.TextBox("termino", "", new { @class = "textinput" })%>


<%=Html.TextBox("termino", "", new { @class = "redborder" }) %>


#termino { border: solid 1px #F00; } 


input[name=termino],
input#termino,
#termino
{
border: 1px solid #f00;
}


To style all text boxes in the blackbar div you can use:

#blackbar input[type='text'] { ... }
0

精彩评论

暂无评论...
验证码 换一张
取 消