Change TextBox Background color on Focus using CSS

In this article, we will change the background color of textbox on Focus using  css . many time we need to change the background color of textbox so we can use this below code.




<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Change TextBox Background Color On CSS</title>
    <style type="text/css">
        input[type=text], textarea
        {
            border: 1px solid #ccc;
        }
        input[type=text]:focus, textarea:focus
        {
            background-color: #66CCCC;
            border: 1px solid #ccc;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <fieldset style="width:350px;">
    <legend>Change TextBox Background Color On Focus</legend>
    <br />
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
    <br />
    <asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine"></asp:TextBox>
   
</fieldset> 
    </form>

</body>
</html>


 Out-Put:-
Change TextBox Background color on Focus using CSS Change TextBox Background color on Focus using CSS Reviewed by NEERAJ SRIVASTAVA on 10:26:00 AM Rating: 5

No comments:

Powered by Blogger.