Form does not rotate around center axis (x,y)





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















Even though I have set [transform-origin: 100% 50%;] in css, the form does not rotate around its center in comparison to X- and Y- axis.



Question: How can I make the form rotate counted exactly from its midpoint.






    .box {
background-color: pink;
margin: 300px 0 0 300px;
width: 200px;
height: 200px;
}

.box {
position: absolute;
animation: spin 10s;
animation-fill-mode: forwards;
}

.line-horizontal {
background-color: black;
width: 200px;
height: 5px;
margin: 100px 0 0 0;
}

.line-vertical {
background-color: black;
width: 5px;
height: 200px;
margin: -105px 0 0 100px;
}

@keyframes spin {
from {
transform:rotate(0deg);
transform-origin: 100% 50%;
}
to {
transform:rotate(360deg);
}
}

    
<div class="box">
<div class="line-horizontal"></div>
<div class="line-vertical"></div>
</div>












share|improve this question




















  • 1





    the center is 50% 50% ... and you should specify this in the element not the keyframe or it will get animated also

    – Temani Afif
    Jan 3 at 10:10











  • transform-origin: center;, which is the same as 50% 50% ... and it is very well showed/explained in the docs, e,g, MDN: developer.mozilla.org/en-US/docs/Web/CSS/transform-origin

    – LGSon
    Jan 3 at 10:16













  • @Temani Afif Your suggestion works. Pls move it into an answer and I will approve it.

    – Toolbox
    Jan 3 at 10:19


















0















Even though I have set [transform-origin: 100% 50%;] in css, the form does not rotate around its center in comparison to X- and Y- axis.



Question: How can I make the form rotate counted exactly from its midpoint.






    .box {
background-color: pink;
margin: 300px 0 0 300px;
width: 200px;
height: 200px;
}

.box {
position: absolute;
animation: spin 10s;
animation-fill-mode: forwards;
}

.line-horizontal {
background-color: black;
width: 200px;
height: 5px;
margin: 100px 0 0 0;
}

.line-vertical {
background-color: black;
width: 5px;
height: 200px;
margin: -105px 0 0 100px;
}

@keyframes spin {
from {
transform:rotate(0deg);
transform-origin: 100% 50%;
}
to {
transform:rotate(360deg);
}
}

    
<div class="box">
<div class="line-horizontal"></div>
<div class="line-vertical"></div>
</div>












share|improve this question




















  • 1





    the center is 50% 50% ... and you should specify this in the element not the keyframe or it will get animated also

    – Temani Afif
    Jan 3 at 10:10











  • transform-origin: center;, which is the same as 50% 50% ... and it is very well showed/explained in the docs, e,g, MDN: developer.mozilla.org/en-US/docs/Web/CSS/transform-origin

    – LGSon
    Jan 3 at 10:16













  • @Temani Afif Your suggestion works. Pls move it into an answer and I will approve it.

    – Toolbox
    Jan 3 at 10:19














0












0








0








Even though I have set [transform-origin: 100% 50%;] in css, the form does not rotate around its center in comparison to X- and Y- axis.



Question: How can I make the form rotate counted exactly from its midpoint.






    .box {
background-color: pink;
margin: 300px 0 0 300px;
width: 200px;
height: 200px;
}

.box {
position: absolute;
animation: spin 10s;
animation-fill-mode: forwards;
}

.line-horizontal {
background-color: black;
width: 200px;
height: 5px;
margin: 100px 0 0 0;
}

.line-vertical {
background-color: black;
width: 5px;
height: 200px;
margin: -105px 0 0 100px;
}

@keyframes spin {
from {
transform:rotate(0deg);
transform-origin: 100% 50%;
}
to {
transform:rotate(360deg);
}
}

    
<div class="box">
<div class="line-horizontal"></div>
<div class="line-vertical"></div>
</div>












share|improve this question
















Even though I have set [transform-origin: 100% 50%;] in css, the form does not rotate around its center in comparison to X- and Y- axis.



Question: How can I make the form rotate counted exactly from its midpoint.






    .box {
background-color: pink;
margin: 300px 0 0 300px;
width: 200px;
height: 200px;
}

.box {
position: absolute;
animation: spin 10s;
animation-fill-mode: forwards;
}

.line-horizontal {
background-color: black;
width: 200px;
height: 5px;
margin: 100px 0 0 0;
}

.line-vertical {
background-color: black;
width: 5px;
height: 200px;
margin: -105px 0 0 100px;
}

@keyframes spin {
from {
transform:rotate(0deg);
transform-origin: 100% 50%;
}
to {
transform:rotate(360deg);
}
}

    
<div class="box">
<div class="line-horizontal"></div>
<div class="line-vertical"></div>
</div>








    .box {
background-color: pink;
margin: 300px 0 0 300px;
width: 200px;
height: 200px;
}

.box {
position: absolute;
animation: spin 10s;
animation-fill-mode: forwards;
}

.line-horizontal {
background-color: black;
width: 200px;
height: 5px;
margin: 100px 0 0 0;
}

.line-vertical {
background-color: black;
width: 5px;
height: 200px;
margin: -105px 0 0 100px;
}

@keyframes spin {
from {
transform:rotate(0deg);
transform-origin: 100% 50%;
}
to {
transform:rotate(360deg);
}
}

    
<div class="box">
<div class="line-horizontal"></div>
<div class="line-vertical"></div>
</div>





    .box {
background-color: pink;
margin: 300px 0 0 300px;
width: 200px;
height: 200px;
}

.box {
position: absolute;
animation: spin 10s;
animation-fill-mode: forwards;
}

.line-horizontal {
background-color: black;
width: 200px;
height: 5px;
margin: 100px 0 0 0;
}

.line-vertical {
background-color: black;
width: 5px;
height: 200px;
margin: -105px 0 0 100px;
}

@keyframes spin {
from {
transform:rotate(0deg);
transform-origin: 100% 50%;
}
to {
transform:rotate(360deg);
}
}

    
<div class="box">
<div class="line-horizontal"></div>
<div class="line-vertical"></div>
</div>






css






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 10:15









Udhay Titus

2,92421532




2,92421532










asked Jan 3 at 10:06









ToolboxToolbox

672312




672312








  • 1





    the center is 50% 50% ... and you should specify this in the element not the keyframe or it will get animated also

    – Temani Afif
    Jan 3 at 10:10











  • transform-origin: center;, which is the same as 50% 50% ... and it is very well showed/explained in the docs, e,g, MDN: developer.mozilla.org/en-US/docs/Web/CSS/transform-origin

    – LGSon
    Jan 3 at 10:16













  • @Temani Afif Your suggestion works. Pls move it into an answer and I will approve it.

    – Toolbox
    Jan 3 at 10:19














  • 1





    the center is 50% 50% ... and you should specify this in the element not the keyframe or it will get animated also

    – Temani Afif
    Jan 3 at 10:10











  • transform-origin: center;, which is the same as 50% 50% ... and it is very well showed/explained in the docs, e,g, MDN: developer.mozilla.org/en-US/docs/Web/CSS/transform-origin

    – LGSon
    Jan 3 at 10:16













  • @Temani Afif Your suggestion works. Pls move it into an answer and I will approve it.

    – Toolbox
    Jan 3 at 10:19








1




1





the center is 50% 50% ... and you should specify this in the element not the keyframe or it will get animated also

– Temani Afif
Jan 3 at 10:10





the center is 50% 50% ... and you should specify this in the element not the keyframe or it will get animated also

– Temani Afif
Jan 3 at 10:10













transform-origin: center;, which is the same as 50% 50% ... and it is very well showed/explained in the docs, e,g, MDN: developer.mozilla.org/en-US/docs/Web/CSS/transform-origin

– LGSon
Jan 3 at 10:16







transform-origin: center;, which is the same as 50% 50% ... and it is very well showed/explained in the docs, e,g, MDN: developer.mozilla.org/en-US/docs/Web/CSS/transform-origin

– LGSon
Jan 3 at 10:16















@Temani Afif Your suggestion works. Pls move it into an answer and I will approve it.

– Toolbox
Jan 3 at 10:19





@Temani Afif Your suggestion works. Pls move it into an answer and I will approve it.

– Toolbox
Jan 3 at 10:19












1 Answer
1






active

oldest

votes


















0














Change the tranform-origin to 50% 50% instead which means the center in both axis and don't put it inside the keyframes because it will get animated






.box {
background-color: pink;
width: 200px;
height: 200px;
}

.box {
position: absolute;
animation: spin 10s;
animation-fill-mode: forwards;
transform-origin: 50% 50%;
/*center*/
}

.line-horizontal {
background-color: black;
width: 200px;
height: 5px;
margin: 100px 0 0 0;
}

.line-vertical {
background-color: black;
width: 5px;
height: 200px;
margin: -105px 0 0 100px;
}

@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

<div class="box">
<div class="line-horizontal"></div>
<div class="line-vertical"></div>
</div>





You can also simplify your code like below in case you need the same visual:






.box {
width: 200px;
height: 200px;
background:
linear-gradient(#000,#000) center/100% 5px,
linear-gradient(#000,#000) center/5px 100%,
pink;
background-repeat:no-repeat;
animation: spin 10s forwards;
transform-origin: 50% 50%; /* OR center*/
}

@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

<div class="box">
</div>








share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020067%2fform-does-not-rotate-around-center-axis-x-y%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Change the tranform-origin to 50% 50% instead which means the center in both axis and don't put it inside the keyframes because it will get animated






    .box {
    background-color: pink;
    width: 200px;
    height: 200px;
    }

    .box {
    position: absolute;
    animation: spin 10s;
    animation-fill-mode: forwards;
    transform-origin: 50% 50%;
    /*center*/
    }

    .line-horizontal {
    background-color: black;
    width: 200px;
    height: 5px;
    margin: 100px 0 0 0;
    }

    .line-vertical {
    background-color: black;
    width: 5px;
    height: 200px;
    margin: -105px 0 0 100px;
    }

    @keyframes spin {
    from {
    transform: rotate(0deg);
    }
    to {
    transform: rotate(360deg);
    }
    }

    <div class="box">
    <div class="line-horizontal"></div>
    <div class="line-vertical"></div>
    </div>





    You can also simplify your code like below in case you need the same visual:






    .box {
    width: 200px;
    height: 200px;
    background:
    linear-gradient(#000,#000) center/100% 5px,
    linear-gradient(#000,#000) center/5px 100%,
    pink;
    background-repeat:no-repeat;
    animation: spin 10s forwards;
    transform-origin: 50% 50%; /* OR center*/
    }

    @keyframes spin {
    from {
    transform: rotate(0deg);
    }
    to {
    transform: rotate(360deg);
    }
    }

    <div class="box">
    </div>








    share|improve this answer






























      0














      Change the tranform-origin to 50% 50% instead which means the center in both axis and don't put it inside the keyframes because it will get animated






      .box {
      background-color: pink;
      width: 200px;
      height: 200px;
      }

      .box {
      position: absolute;
      animation: spin 10s;
      animation-fill-mode: forwards;
      transform-origin: 50% 50%;
      /*center*/
      }

      .line-horizontal {
      background-color: black;
      width: 200px;
      height: 5px;
      margin: 100px 0 0 0;
      }

      .line-vertical {
      background-color: black;
      width: 5px;
      height: 200px;
      margin: -105px 0 0 100px;
      }

      @keyframes spin {
      from {
      transform: rotate(0deg);
      }
      to {
      transform: rotate(360deg);
      }
      }

      <div class="box">
      <div class="line-horizontal"></div>
      <div class="line-vertical"></div>
      </div>





      You can also simplify your code like below in case you need the same visual:






      .box {
      width: 200px;
      height: 200px;
      background:
      linear-gradient(#000,#000) center/100% 5px,
      linear-gradient(#000,#000) center/5px 100%,
      pink;
      background-repeat:no-repeat;
      animation: spin 10s forwards;
      transform-origin: 50% 50%; /* OR center*/
      }

      @keyframes spin {
      from {
      transform: rotate(0deg);
      }
      to {
      transform: rotate(360deg);
      }
      }

      <div class="box">
      </div>








      share|improve this answer




























        0












        0








        0







        Change the tranform-origin to 50% 50% instead which means the center in both axis and don't put it inside the keyframes because it will get animated






        .box {
        background-color: pink;
        width: 200px;
        height: 200px;
        }

        .box {
        position: absolute;
        animation: spin 10s;
        animation-fill-mode: forwards;
        transform-origin: 50% 50%;
        /*center*/
        }

        .line-horizontal {
        background-color: black;
        width: 200px;
        height: 5px;
        margin: 100px 0 0 0;
        }

        .line-vertical {
        background-color: black;
        width: 5px;
        height: 200px;
        margin: -105px 0 0 100px;
        }

        @keyframes spin {
        from {
        transform: rotate(0deg);
        }
        to {
        transform: rotate(360deg);
        }
        }

        <div class="box">
        <div class="line-horizontal"></div>
        <div class="line-vertical"></div>
        </div>





        You can also simplify your code like below in case you need the same visual:






        .box {
        width: 200px;
        height: 200px;
        background:
        linear-gradient(#000,#000) center/100% 5px,
        linear-gradient(#000,#000) center/5px 100%,
        pink;
        background-repeat:no-repeat;
        animation: spin 10s forwards;
        transform-origin: 50% 50%; /* OR center*/
        }

        @keyframes spin {
        from {
        transform: rotate(0deg);
        }
        to {
        transform: rotate(360deg);
        }
        }

        <div class="box">
        </div>








        share|improve this answer















        Change the tranform-origin to 50% 50% instead which means the center in both axis and don't put it inside the keyframes because it will get animated






        .box {
        background-color: pink;
        width: 200px;
        height: 200px;
        }

        .box {
        position: absolute;
        animation: spin 10s;
        animation-fill-mode: forwards;
        transform-origin: 50% 50%;
        /*center*/
        }

        .line-horizontal {
        background-color: black;
        width: 200px;
        height: 5px;
        margin: 100px 0 0 0;
        }

        .line-vertical {
        background-color: black;
        width: 5px;
        height: 200px;
        margin: -105px 0 0 100px;
        }

        @keyframes spin {
        from {
        transform: rotate(0deg);
        }
        to {
        transform: rotate(360deg);
        }
        }

        <div class="box">
        <div class="line-horizontal"></div>
        <div class="line-vertical"></div>
        </div>





        You can also simplify your code like below in case you need the same visual:






        .box {
        width: 200px;
        height: 200px;
        background:
        linear-gradient(#000,#000) center/100% 5px,
        linear-gradient(#000,#000) center/5px 100%,
        pink;
        background-repeat:no-repeat;
        animation: spin 10s forwards;
        transform-origin: 50% 50%; /* OR center*/
        }

        @keyframes spin {
        from {
        transform: rotate(0deg);
        }
        to {
        transform: rotate(360deg);
        }
        }

        <div class="box">
        </div>








        .box {
        background-color: pink;
        width: 200px;
        height: 200px;
        }

        .box {
        position: absolute;
        animation: spin 10s;
        animation-fill-mode: forwards;
        transform-origin: 50% 50%;
        /*center*/
        }

        .line-horizontal {
        background-color: black;
        width: 200px;
        height: 5px;
        margin: 100px 0 0 0;
        }

        .line-vertical {
        background-color: black;
        width: 5px;
        height: 200px;
        margin: -105px 0 0 100px;
        }

        @keyframes spin {
        from {
        transform: rotate(0deg);
        }
        to {
        transform: rotate(360deg);
        }
        }

        <div class="box">
        <div class="line-horizontal"></div>
        <div class="line-vertical"></div>
        </div>





        .box {
        background-color: pink;
        width: 200px;
        height: 200px;
        }

        .box {
        position: absolute;
        animation: spin 10s;
        animation-fill-mode: forwards;
        transform-origin: 50% 50%;
        /*center*/
        }

        .line-horizontal {
        background-color: black;
        width: 200px;
        height: 5px;
        margin: 100px 0 0 0;
        }

        .line-vertical {
        background-color: black;
        width: 5px;
        height: 200px;
        margin: -105px 0 0 100px;
        }

        @keyframes spin {
        from {
        transform: rotate(0deg);
        }
        to {
        transform: rotate(360deg);
        }
        }

        <div class="box">
        <div class="line-horizontal"></div>
        <div class="line-vertical"></div>
        </div>





        .box {
        width: 200px;
        height: 200px;
        background:
        linear-gradient(#000,#000) center/100% 5px,
        linear-gradient(#000,#000) center/5px 100%,
        pink;
        background-repeat:no-repeat;
        animation: spin 10s forwards;
        transform-origin: 50% 50%; /* OR center*/
        }

        @keyframes spin {
        from {
        transform: rotate(0deg);
        }
        to {
        transform: rotate(360deg);
        }
        }

        <div class="box">
        </div>





        .box {
        width: 200px;
        height: 200px;
        background:
        linear-gradient(#000,#000) center/100% 5px,
        linear-gradient(#000,#000) center/5px 100%,
        pink;
        background-repeat:no-repeat;
        animation: spin 10s forwards;
        transform-origin: 50% 50%; /* OR center*/
        }

        @keyframes spin {
        from {
        transform: rotate(0deg);
        }
        to {
        transform: rotate(360deg);
        }
        }

        <div class="box">
        </div>






        share|improve this answer














        share|improve this answer



        share|improve this answer








        answered Jan 3 at 10:27


























        community wiki





        Temani Afif

































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020067%2fform-does-not-rotate-around-center-axis-x-y%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith