Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用jquery在单击时切换框阴影_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 如何使用jquery在单击时切换框阴影

Javascript 如何使用jquery在单击时切换框阴影,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我正在尝试更改单击div上的框阴影。这是我的代码 index.html <html> <head> <script src="jquery-3.2.1.min.js"></script> <link rel="stylesheet" href="style.css"> </head> <body> <div id="ttt">&

我正在尝试更改单击div上的框阴影。这是我的代码

index.html

<html>
    <head>

        <script src="jquery-3.2.1.min.js"></script>
        <link rel="stylesheet" href="style.css">
    </head>
    <body>
        <div id="ttt"></div>
        <script src="script.js"></script>
    </body>
</html>
style.css

$(document).ready(function () {
    var state = false;
    $("#ttt").click(function () {
        if (state) {
            $("#ttt").animate({
                'boxShadowX': '10px',
                'boxShadowY': '10px',
                'boxShadowBlur': '20px'
            });
        } else {
            $("#ttt").animate({
                'boxShadowX': '3px',
                'boxShadowY': '3px',
                'boxShadowBlur': '3px'
            });
        }
        console.log(state);
        state = !state;
    });

});
#ttt{
    padding-left: 100px;
    padding-top: 100px;
    padding-right: 100px;
    padding-bottom: 100px;
    width: 100px;
    height: 100px;
    background-color: red;
    border-radius: 10px;
    box-shadow: 10px 10px 5px #888888;
}

如何使用jquery切换框显示,使其在鼠标单击时从完全可见变为精简动画?

使用Edwin Martin的用于阴影动画的jquery插件,它扩展了.animate方法,您可以简单地使用带有“boxShadow”的普通语法以及该方法的各个方面-“颜色、x和y偏移、模糊半径和扩散半径”设置动画:

$(selector).animate({ boxShadow : "0 0 5px 3px rgba(100,100,200,0.4)" }); 

编辑:现在包括多个阴影支持。

使用Edwin Martin的用于阴影动画的jQuery插件,该插件扩展了.animate方法,您可以简单地使用“boxShadow”的常规语法,其中的每个方面——“颜色、x和y偏移、模糊半径和扩散半径”都可以设置动画:

$(selector).animate({ boxShadow : "0 0 5px 3px rgba(100,100,200,0.4)" }); 
编辑:现在包括多个阴影支持。

可能重复的阴影可能重复的阴影