简体   繁体   English

旋转动画不适用于跨度ID

[英]Rotate animation not working on span ID

The animation works but it only fades it. 动画有效,但只会使其淡出。 No rotation like it is supposed to. 不会像预期的那样旋转。 I tried it on a div id and it worked. 我在div id上尝试过,它起作用了。

Is my span code correct? 我的验证码正确吗? or any errors? 还是有任何错误?

<p style="text-align: center;"><span id="jrm-featured-products" style="font-family: Poiret One; font-size: 36px;">Featured  Products</span></p>

And here is my CSS :- 这是我的CSS:-

 @-webkit-keyframes rotateInDownLeft {
    0% {
       -webkit-transform-origin: left bottom;
        transform-origin: left bottom;
       -webkit-transform: rotate(-90deg);
        transform: rotate(-90deg);
        opacity: 0;
    }

    100% {
        -webkit-transform-origin: left bottom;
         transform-origin: left bottom;
        -webkit-transform: rotate(0);
         transform: rotate(0);
         opacity: 1;
      }
    }

    @keyframes rotateInDownLeft {
    0% {
    -webkit-transform-origin: left bottom;
    -ms-transform-origin: left bottom;
    transform-origin: left bottom;
    -moz-transform-origin: left bottom;
    -webkit-transform: rotate(-90deg);
    -ms-transform: rotate(-90deg);
    transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    opacity: 0;
    }

    100% {
         -webkit-transform-origin: left bottom;
         -ms-transform-origin: left bottom;
          transform-origin: left bottom;
         -moz-transform-origin: left bottom;
         -webkit-transform: rotate(0);
         -ms-transform: rotate(0);
          transform: rotate(0);
         -moz-transform: rotate(0);
          opacity: 1;
      }
    }

    #jrm-featured-products.animate {
         -webkit-animation: rotateInDownLeft 3s;
         -moz-animation: rotateInDownLeft 3s;
          animation-name: rotateInDownLeft;
         visibility: visible;
    }

    #jrm-featured-products {
         visibility:  hidden;
    }

The animation works but it only fades it. 动画有效,但只会使其淡出。 No rotation like it is supposed to. 不会像预期的那样旋转。 I tried it on a div id and it worked. 我在div id上尝试过,它起作用了。

Is my span code correct? 我的验证码正确吗? or any errors? 还是有任何错误?

PS I'm using the jquery plugin Waypoints so that is why there is a .animate. PS我正在使用jquery插件Waypoint,所以这就是为什么有一个.animate的原因。 (it toggles it hence creating the animation when the elemet comes into view) but that isn't too relevant to my problem. (它会切换它,因此当元件出现时会创建动画),但这与我的问题不太相关。

Also, i'll spare you the long story, but I really need it to target the span id rather than the div id. 另外,我将不遗余力地介绍您的情况,但我确实需要它来定位范围ID而不是div ID。

thanks! 谢谢!

Set the span to display: block . 将范围设置为display: block

<span> elements are, by default, set to display: inline , while <div> elements are, by default, set to display: block . <span>元素默认设置为display: inline ,而<div>元素默认设置为display: block Only block level elements can be transformed . 只能转换块级元素 Though a span isn't a block level element, you can make it behave as one by settings its display property to block . 尽管跨度不是块级元素,但是可以通过将其display属性设置为block来使其表现出整体性。

Read more about inline vs block level elements here: http://www.impressivewebs.com/difference-block-inline-css/ 在此处阅读有关内联与块级元素的更多信息: http : //www.impressivewebs.com/difference-block-inline-css/

Div takes the whole row as its width,but span width area is only the area covered by the text or the image,so it is not getting place to rotate,give some width to span by style="width:500px" Div以整行为宽度,但span width区域仅是文本或图像覆盖的区域,因此它没有旋转的地方,请通过style =“ width:500px”给一些宽度进行跨越

because span is INLINE and div is BLOCK 因为span是INLINE而div是BLOCK

将跨度显示设置为“块”,默认跨度为嵌入式元素

Try using display: inline-block 尝试使用display: inline-block

The span's width will shrink to fit with the content 跨度的宽度将缩小以适合内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM