Reputation: 182
I have a problem with JQuery and inset Box-Shadow.
First of all I have a input field.
<input id="name" name="name" type="text" />
That field has the following css styles:
#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;
}
Okay. Now the JQuery part:
What I want to do! If I hover over my input field i want an "outer" box-shadow. Like: boxShadow: "0px 0px 15px #750082". But the inset box-shadow should be the same!!
$(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"});
});
});
The problem is that the "outer" box shadow will be displayed as an inset box-shadow. But I want an "outer" box-shadow and a inset box-shadow!
So whats wrong with my solution? Has someone a better one?
Best regards
edit I'm using JQuery 1.6.2, for the boxshadow I'm using http://www.bitstorm.org/jquery/shadow-animation/test.html Plugin!
Upvotes: 2
Views: 4885
Reputation: 27415
here are two options to get the same desired result
1: Use a wrapper for the <input>
<span id="nameWrapper">
<input id="name" name="name" type="text" value="" />
</span>
jQuery:
$("#name").hover(function() {
$(this).parent().stop().animate({
boxShadow: "0px 0px 15px #750082"
}, 800);
}, function() {
$(this).parent().stop().animate({
boxShadow: ""
}, 800);
});
2: Use CSS3 transitions instead
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;
}
you may consider writing the author of the shadow plugin to notify him/her of this issue.
Upvotes: 5