Svg 同时在 2 行上设置带有动画的新坐标

tur*_*roy 1 html css jquery svg

我需要一种方法(使用 CSS3 或 jQuery)将此 SVG 形状从(向下箭头)更改X?(向下箭头)。我尝试了更多方法,但仍然有问题。

我的基本想法是获取带有 id ( svg_5, svg_6) 的线条并将它们作为箭头的头部。

$('a').click(function (e) {
    if ($('.formJ').css('visibility') == 'hidden')
        $('.formJ').css('visibility', 'visible');
    else
        $('.formJ').css('visibility', 'hidden');
    e.preventDefault();
});

$("a").bind({
    mouseover: function () {
        $("circle").css({ "stroke": "#80C6E7", "fill": "white" })
        $("line").css({ "stroke": "#80C6E7" })
    },
    mouseout: function () {
        $("circle").css({ "stroke": "white", "fill": "#80C6E7" })
        $("line").css({ "stroke": "white" })
    }
});

$("element").unbind('mouseover mouseout');
Run Code Online (Sandbox Code Playgroud)
body {
    background: #80C6E7;
}
a, a:active, a:hover {
    text-decoration: none;
    outline: 0;
}
.wrap {
    width: 260px;
    margin: auto;
}
.formindex {
    display: none;
}
.formJ {
    visibility: hidden;
} 
.hex-icon-plus line {
    transform-origin: 100px 100px;
    -webkit-transform-origin: 100px 100px;
    animation: hex-icon-heart-beat 2s linear infinite;
    -webkit-animation: hex-icon-heart-beat 2s linear infinite;
    -webkit-animation-delay: 0s; /* Chrome, Safari, Opera */
}

@keyframes hex-icon-heart-beat {
    0% {
        transform: scale3d(1, 1, 1);
    }
    30% {
        transform: scale3d(0.90, 0.90, 1);
    }
    60% {
        transform: scale3d(1, 1, 1);
    }
}

@-webkit-keyframes hex-icon-heart-beat {
    0% {
        -webkit-transform: scale3d(1, 1, 1);
    }
    30% {
        -webkit-transform: scale3d(0.90, 0.90, 1);
    }
    60% {
        -webkit-transform: scale3d(1, 1, 1);
    }
}
svg {
    padding-top: 20%;
    margin: 12%;
}
h1 {
    color: white;
    text-align: center;
    margin-bottom: 12px;
}
.loginform-in {
    width: 200px;
    margin: 25px;
    margin-top: 60px;
}
input {
    margin-bottom: 12px;
}
.loginbutton {
    background: #2C3E50;
    border: 1px solid #2C3E50;   
    color: #80C6E7;
    cursor: pointer;
    font-size: 13px;
    font-weight: normal;
    height: 29px;
    letter-spacing: 1px;
    width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <link rel="stylesheet" type="text/css" href="../CSS/reset.css" />
    <link rel="stylesheet" type="text/css" href="../CSS/style.css" />
    <link rel="stylesheet" type="text/css" href="../CSS/formStyle.css" />
    <title></title>
</head>
<body>
    <div class="wrap">
        <span class="hex-icon-plus">
            <a href="Form.html">
                <svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
                    <g>
                        <circle fill="none" stroke="#ffffff" stroke-width="2" cx="101.874999" cy="101.000003" r="97.070312" id="svg_2" />
                        <line fill="none" stroke="#ffffff" stroke-width="5" stroke-dasharray="null" stroke-linejoin="null" stroke-linecap="null" x1="100.1875" y1="40.375009" x2="100.1875" y2="160.437515" id="svg_4" />
                        <line fill="none" stroke="#ffffff" stroke-width="5" stroke-dasharray="null" stroke-linejoin="null" stroke-linecap="null" x1="41.14063" y1="100" x2="161.078126" y2="101" id="svg_5" />
                        <line fill="none" stroke="#ffffff" stroke-width="5" stroke-dasharray="null" stroke-linejoin="null" stroke-linecap="null" x1="41.14063" y1="100" x2="161.078126" y2="101" id="svg_6" />
                    </g>
                </svg>
            </a>
        </span>
        <div class="loginform-in formJ">
            <fieldset>
                <form action="Users.html" method="get">
                    <h1>User</h1>
                    <ul>
                        <li>
                            <label for="name"></label>
                            <input type="text" size="30" name="name" placeholder="Name" id="name" />
                        </li>
                        <li>
                            <label for="name"></label>
                            <input type="password" size="30" name="word" placeholder="Password" id="word" />
                        </li>
                        <li>
                            <label></label>
                            <input type="submit" id="login" name="login" value="Login" class="loginbutton" />
                        </li>
                    </ul>
                </form>
            </fieldset>
        </div>
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="../Scripts/form.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我想要的结果是这个形状

<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
    <g>
        <circle id="svg_2" r="97.07031" cy="101" cx="101.875" stroke-width="2" stroke="#000000" fill="none"/>
        <line id="svg_4" y2="160.43751" x2="100.1875" y1="40.37501" x1="100.1875" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="none"/>
        <line id="svg_5" y2="101.0001" x2="161.07813" y1="158.55503" x1="101.11938" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="none"/>
        <line id="svg_6" y2="158.48696" x2="99.49754" y1="99.99989" x1="41.14063" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="none"/>
    </g>
</svg>
Run Code Online (Sandbox Code Playgroud)

Ian*_*Ian 5

如果那是一个选项,你当然可以用纯 SVG 来做到这一点,不确定甚至需要 css/jquery。

您可以变形路径,只要它们在路径中具有相同数量的点,因此这意味着一条路径而不是一条线。

<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
  <g id="mycross">

     <circle fill="none" stroke="black" stroke-width="2" cx="101.874999" cy="101.000003" r="97.070312" id="svg_2" />
     <path id="mypath" d="M50,100L90,100L150,100" stroke="black" stroke-width="2" fill="none"/>
     <path id="vertline" d="M100,50L100,150" stroke="black" stroke-width="2"/>
     <animate xlink:href="#mypath" attributeName="d" from="M50,100L100,100L150,100" to="M50,100L100,150L150,100" dur="2s" begin="mycross.click" fill="freeze" />

  </g>
</svg>
Run Code Online (Sandbox Code Playgroud)

提琴手