You'll find they use a combination of JavaScript with CSS3 to create this effect.
They will have an event handler that handles the onfocus state of the textbox and then use the CSS3 box-shadow style along with a Javascript fade effect,
The best (easiest) way to achieve this would be to combine jQuery with CSS3 properties, But can also be done in raw JS at the same time, If you need further explanation just leave a comment.
They use png image for div which is moved behind input field and hidden when there's no focus. Everything has fixed width and height so no imege resizing needed.
Didn't see any CSS3 or HTML5 there but to do it with CSS3 than with border-image it should be possible to achieve the same effect, something like:
border-image: url("border.png") 10;
Edit:
@Lea Verou has better solution. I added this effect to one of my sites yesterday like this
发布评论
评论(3)
:focus { box-shadow: 0 0 10px 红色; }
发出红光。本质上,发光是具有合适颜色且无偏移的阴影。:focus { box-shadow: 0 0 10px red; }
for a red glow. Essentially a glow is a drop shadow with a suitable color and no offset.您会发现他们使用 JavaScript 和 CSS3 的组合来创建这种效果。
他们将有一个事件处理程序来处理文本框的
onfocus
状态,然后使用 CSS3box-shadow
样式以及 Javascript 淡入淡出效果,这是最好(最简单)的方法要实现这一点,需要将 jQuery 与 CSS3 属性结合起来,但也可以同时在原始 JS 中完成,如果您需要进一步解释,请发表评论。
You'll find they use a combination of JavaScript with CSS3 to create this effect.
They will have an event handler that handles the
onfocus
state of the textbox and then use the CSS3box-shadow
style along with a Javascript fade effect,The best (easiest) way to achieve this would be to combine jQuery with CSS3 properties, But can also be done in raw JS at the same time, If you need further explanation just leave a comment.
他们使用 png 图像作为 div,该图像被移动到输入字段后面,并在没有焦点时隐藏。所有东西都有固定的宽度和高度,因此不需要调整图像大小。
那里没有看到任何 CSS3 或 HTML5,但使用 CSS3 比使用 border-image 应该可以达到相同的效果,例如:
编辑:
@Lea Verou 有更好的解决方案。我昨天在我的一个网站上添加了这个效果,就像这样
一些适用于 IE 的 javascript (我自己没有写),因为它不支持 :focus
要向 IE 添加框阴影支持,使用了 CSS3PIE。就像魅力一样。
They use png image for div which is moved behind input field and hidden when there's no focus. Everything has fixed width and height so no imege resizing needed.
Didn't see any CSS3 or HTML5 there but to do it with CSS3 than with border-image it should be possible to achieve the same effect, something like:
Edit:
@Lea Verou has better solution. I added this effect to one of my sites yesterday like this
Some javascript (didn't write it myself) for IE as it doesn't support :focus
To add box-shadow support to IE used CSS3PIE. Works like a charm.