PDA

View Full Version : [CLOSED] CSS Class : How to set CSS class to TextField



matrixwebtech
Jan 22, 2015, 5:45 PM
I am trying to add a css class to text field.my code like bellow.but textfield not take effect


@using Ext.Net.MVC

@Html.X().ResourceManager()
@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<style>
.input {
border: 1px solid #CCCCCC;
font-size: 14px;
font-weight: bold;
width: 225px;
height: 18px;
margin-top: 2px;
padding: 5px 2px 2px;
}
</style>
</head>
<body>
<div>
@(Html.X().TextField()
.ID("txtUsername")
.ReadOnly(false)
.HideLabel(true)
.AllowBlank(false)
.Border(false)
.BlankText("Your username is required.")
.Cls("input")

)
<br />
<input name="txtPass" type="password" id="txtPass" tabindex="3" class="input" />
</div>
</body>
</html>

Daniil
Jan 23, 2015, 10:42 AM
Hi @matrixwebtech,

Please clarify have you inspected HTML elements and its CSS rules? Usually, inspecting help to understand and determine what changes are required.

matrixwebtech
Jan 23, 2015, 3:22 PM
Thanks for tips.I override default css with same class name and !important .am I follow correct technique?


.x-form-text {
background: none !important;
}

smmille1
Jan 23, 2015, 7:50 PM
If you want it changed for every field, then your technique applies, although I don't think !important is necessary as long as your rule is applied last. If you only want to change some fields, then specify a Cls for those fields and use CSS like
.my-custom-textfield-cls .x-form-text {
background: none;
}