JQuery Box-shadow插入问题

Pau*_*ell 2 css jquery css3

我有一个问题与JQuery和插入Box-Shadow.

首先,我有一个输入字段.

<input id="name" name="name" type="text" />
Run Code Online (Sandbox Code Playgroud)

该字段具有以下css样式:

 #contact input[type="text"] {
     background: rgba(55,55,55, 0.6);
     height:2em;
     border: 1px dashed #666;
     width:200px;
     box-shadow:inset 0px 0px 10px #222;
     border-radius: 2px;
}
Run Code Online (Sandbox Code Playgroud)

好的.现在JQuery部分:

我想做的事!如果我将鼠标悬停在输入字段上,我想要一个"外部"框阴影.喜欢:boxShadow:"0px 0px 15px#750082".但插入的盒子阴影应该是一样的!!

$(document).ready(function(){
    $("#message").hover(
        function()
            {$(this).stop().animate({boxShadow: "0px 0px 15px #750082"},800);
            },
        function()
            {$(this).stop().animate({boxShadow: "inset 0px 0px 10px #222222"});

    });
});
Run Code Online (Sandbox Code Playgroud)

问题是"外部"框阴影将显示为插入框阴影.但我想要一个"外部"盒子阴影和一个插入盒子阴影!

那么我的解决方案有什么问题吗?谁有人更好?

最好的祝福

编辑 我正在使用JQuery 1.6.2,我正在使用http://www.bitstorm.org/jquery/shadow-animation/test.html插件的boxshadow !

Mik*_*keM 5

这里有两个选项可以获得相同的结果

示例jsfiddle

1:使用包装纸 <input>

<span id="nameWrapper">
    <input id="name" name="name" type="text" value="" />
</span>
Run Code Online (Sandbox Code Playgroud)

jQuery的:

$("#name").hover(function() {
    $(this).parent().stop().animate({
        boxShadow: "0px 0px 15px #750082"
    }, 800);
}, function() {
    $(this).parent().stop().animate({
        boxShadow: ""
    }, 800);
});
Run Code Online (Sandbox Code Playgroud)

2:改为使用CSS3过渡

CSS:

#contact input[type="text"] {
    background: rgba(55,55,55, 0.6);
    height:2em;
    border: 1px dashed #666;
    width:200px;
    box-shadow:inset 0px 0px 10px #222;
    border-radius: 2px;
    outline:0;/* prevent webkit highlight on focus */
    -webkit-transition: all 0.8s ease-in-out;
       -moz-transition: all 0.8s ease-in-out;
        -ms-transition: all 0.8s ease-in-out;
         -o-transition: all 0.8s ease-in-out;
            transition: all 0.8s ease-in-out;
}
#contact input[type="text"]:hover {
    /* set both shadows */
    box-shadow:inset 0px 0px 10px #222,0px 0px 15px #750082;
}
Run Code Online (Sandbox Code Playgroud)

你可以考虑编写影子插件的作者来通知他/她这个问题.