FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

highlighted text boxes

 


riyadh
how do i code my stylesheet so tht when a user clicks on a text box to write something the border colour of the text box changes?
alem
after looking w3schools.org and Lisssa Explains.com i wrote this little code:
this part in your stylesheet:
Code:
  textarea{
  border-color: green;
  border-style: solid;
  }

and this part in your body whereever you want:
Code:
<textarea rows="3" cols="70" onfocus="this.style.borderColor = 'red';" onblur="this.style.borderColor = 'green';">
The cat was playing in the garden. Suddenly a dog showed up.....
</textarea>

also you can find other attributes in the given webpage...
mathiaus
Another way is to use the below. Its only hover as opposed to actually clicking in it, but it will work for those without javascript as well Smile
Code:
textarea:hover { border: 1px solid red; }



EDIT: Use jylan's below. He's got it! Smile


Last edited by mathiaus on Fri Aug 24, 2007 9:29 am; edited 1 time in total
jylan
Hi riyadh,

To put a border around the textarea use alem's css code. You can then use the :focus pseudo-class to change the style of the textarea when a user selects it. See my code below.
Code:

textarea {
  border:1px solid green;
}

textarea:focus {
  border:1px solid red;
}
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.