CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   HTML & CSS (http://www.codingforums.com/forumdisplay.php?f=13)
-   -   input field color help (http://www.codingforums.com/showthread.php?t=275431)

legendrock7 10-06-2012 02:42 AM

input field color help
 
Hi, i found a website that there input field is colored & brightens once u click on the field. How do i do that? Here's my input field code

Code:

<input name="name" value="Server Name" /><br><input name="ip" value="Server IP" /><br><input name="port" value="Server Port" />

sunfighter 10-06-2012 05:46 AM

First added css to get a back ground color. Then added an ID so the back ground color knows what to color. Then added onfocus, it could have been an onclick, to change the color via a javascript command. I only added it to the first input.

Code:

<!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" xml:lang="en" lang="en">
<head>
<style type="text/css">
#name, #ip, #port{
        background-color: SlateGray;
}
</style>
</head>
<body>
<input id="name" onfocus="this.style.backgroundColor='silver';" name="name" value="Server Name" /><br />
<input id="ip" name="ip" value="Server IP" /><br />
<input id="port" name="port" value="Server Port" />
</body>
</html>



All times are GMT +1. The time now is 03:55 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.