Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.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
Jquery 是否可以设置动画并从元素中删除伪内容。。?_Jquery_Css_Jquery Animate_Css Animations_Pseudo Element - Fatal编程技术网

Jquery 是否可以设置动画并从元素中删除伪内容。。?

Jquery 是否可以设置动画并从元素中删除伪内容。。?,jquery,css,jquery-animate,css-animations,pseudo-element,Jquery,Css,Jquery Animate,Css Animations,Pseudo Element,我有一个按钮,当用户单击该按钮时,我正在使用伪内容在按钮上添加一个“勾号”:在之前,它工作正常 但是我需要用2sec删除:before属性的fadeOut()。有可能吗 这是我的按钮css代码: button{ border: 1px solid #1f85c3; height: 30px; color: #fff; padding: .4em 1em !important; background-image: linear-gradient(#1f96d

我有一个按钮,当用户单击该按钮时,我正在使用伪内容在按钮上添加一个“勾号”:在之前,它工作正常

但是我需要用2sec删除
:before
属性的
fadeOut()
。有可能吗

这是我的按钮css代码:

button{
    border: 1px solid #1f85c3;
    height: 30px;
    color: #fff;
    padding: .4em 1em !important;
    background-image: linear-gradient(#1f96d0, #007cc2);
    position: relative;
    display: block;
    padding-right: 30px !important;
}
单击“我正在添加类名”
right

button.right:before{
    content: '';
    position: absolute;
    top: 50%;
    right: 0%;
    margin: -7px 0 0 -10px;
    height: 5px;
    width: 16px;
    border: solid #FFF;
    border-width: 0 0 5px 5px;
    -webkit-transform: rotate(-45deg);
    -moz-transform: rotate(-45deg);
    -ms-transform: rotate(-45deg);
    -o-transform: rotate(-45deg);
    transform: rotate(-45deg);
    -webkit-box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.4);
    box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.4);
}

有什么建议吗?

因为您要在单击时添加
类,所以您可以为按钮创建一个空的
:before
伪元素并使用转换

button:before{
    content:'';
    opacity:1;
    transition:opacity 2s linear;
}
并将
opacity:0
添加到
按钮。右:在规则之前

button.right:before{
    content: '';
    position: absolute;
    top: 50%;
    right: 0%;
    margin: -7px 0 0 -10px;
    height: 5px;
    width: 16px;
    border: solid #FFF;
    border-width: 0 0 5px 5px;
    -webkit-transform: rotate(-45deg);
    -moz-transform: rotate(-45deg);
    -ms-transform: rotate(-45deg);
    -o-transform: rotate(-45deg);
    transform: rotate(-45deg);
    -webkit-box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.4);
    box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.4);

    opacity:0;
}
演示在


(我只添加了转换的标准属性,如果需要,您应该添加特定于供应商的前缀。)

由于您要在单击时添加
right
类,您可以为按钮创建一个空的
:before
伪元素并使用转换

button:before{
    content:'';
    opacity:1;
    transition:opacity 2s linear;
}
并将
opacity:0
添加到
按钮。右:在规则之前

button.right:before{
    content: '';
    position: absolute;
    top: 50%;
    right: 0%;
    margin: -7px 0 0 -10px;
    height: 5px;
    width: 16px;
    border: solid #FFF;
    border-width: 0 0 5px 5px;
    -webkit-transform: rotate(-45deg);
    -moz-transform: rotate(-45deg);
    -ms-transform: rotate(-45deg);
    -o-transform: rotate(-45deg);
    transform: rotate(-45deg);
    -webkit-box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.4);
    box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.4);

    opacity:0;
}
演示在


(我只添加了转换的标准属性,如果需要,您应该添加特定于供应商的前缀。)

jQuery无法访问psuedo元素,因此无法用于执行您需要的操作。如果您使用jQuery,为什么不只预加一个元素,然后设置jQuery无法访问psuedo元素的动画,如果您使用的是jQuery,为什么不只是预先添加一个元素,然后设置它的动画呢