tags:

views:

1555

answers:

5

Hi friends,

Make glowing effect around the text box while placing the cursor inside the textbox. For example : just place the cursor inside the search textbox in our stackoverflow.com.

Its because of css, but i dont know how to achieve it.. Please help me.

+2  A: 

Outline property

http://www.w3schools.com/css/pr_outline.asp

If you want it to appear when clicking on a text box:

input:focus { outline: /* whatever */ }

IE7 doesn't support the :focus selector, but you can use jQuery:

$("input").focus(function () {
     $(this).css('outline','yellow solid thin');
});
Tyler Rash
yes, but in need this same, while cursor inside the textbox, if its comes out then it will act as normal textbox
praveenjayapal
Are you saying that you want the outline whether the focus is on the textbox or not? You can use the input selector for that (instead of input:focus).
Tyler Rash
yes its working, but in IE its not working. I am having IE7
praveenjayapal
IE7 doesn't support the :focus selector, I edited my answer to include a jQuery workaround.
Tyler Rash
IE7 doesn't support outline either
SpliFF
Ha, that's an excellent point.
Tyler Rash
A: 

I might be wrong, but I think all browsers on my Mac OS X do that for all edit boxes. It's the system behavior.

ilya n.
yes, i can understand now. But is it possible to do like that using css and javascript
praveenjayapal
A: 

I would use an animated gif and use my css to get the text box inside the animated gif.

Try this link for a tutorial on css overlays: http://www.websiteoptimization.com/speed/tweak/overlay/

You will also want to use javascript to either hide or change the image when the text box gains and loses focus.

John JJ Curtis
+2  A: 

While the effect you observe on the stackoverflow search box is probably browser specific (e.g. Google Chrome) there is a way to achieve what you want using the CSS :focus pseudo class:

#foo:focus { border: 2px solid red; }
<input id="foo" type="text"/>
Josef
The outline property is more appropriate here than setting the border.
Tyler Rash
yes its working, but in IE its not working. I am having IE7
praveenjayapal
You're right, the outline property is more appropriate here. It doesn't work in IE however but neither does the :focus pseudo class..
Josef
+1  A: 

Obviously outline isn't supported by IE7 and even if it was I doubt it would "glow". You need to do this with a custom background image or something. There's an example of doing that here:

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/CSS/Q_24084560.html

BTW: You say "border color". A border is not an outline. You can just use:

<input onfocus="this.style.border='2px solid yellow'">

You can do it with the CSS :focus pseudo-class but chances are IE6/7 doesn't support it.

SpliFF