CSS3知识汇总19:transform-origin

用来指定元素的中心点位置

top = top center = center top     50% 0

right = right center = center right   100%(或100% 50%)

bottom = bottom center = center bottom   50%  100%

left = left center = center left   0% (或0% 50%)

center = center center   50% (或50% 50%)

top left = left top   0% 0%

top right =  right top  100% 0

bottom left = left bottom  0% 100%

bottom right = right bottom  100% 100%

.outer{

    width: 100px;

    height: 100px;

    background-color: #6a5acd;

    margin:200px;

}

.inner{

    width: 100%;

    height: 100%;

    background-color: #6acdeb;

    transform: rotate(10deg);

    transform-origin: 0 0;/*以左上角旋转*/

}

【扩展练习:加载条】

<div class="outer">

    <div class="inner"></div>

    <div class="inner"></div>

    <div class="inner"></div>

    <div class="inner"></div>

</div>

html,body{

    display: flex;

    flex-direction: column;

    justify-content: center;

    align-items: center;

    margin:0 auto;

    height: 100%;

    width: 100%;

}

.outer{

    display: flex;

    justify-content: center;

    width: 100px;

    height: 100px;

    /*background-color: #6a5acd;*/

    position: relative;

}

.inner{

    position:absolute;

    width: 20px;

    height: 20px;

    border-radius: 50%;

    background-color: black;

    transform-origin: 50% 50px;

    animation: an-circle 3s ease-in-out infinite;

}

.inner:nth-child(2){

    height: 18px;

    width: 18px;

    animation-delay: .2s;/*等待2秒后动画*/

}

.inner:nth-child(3){

    height: 16px;

    width: 16px;

    animation-delay: .4s;

}

.inner:nth-child(4){

    height: 14px;

    width: 14px;

    animation-delay: .6s;

}

@keyframes an-circle{

    to{

        transform: rotate(1turn);

    }

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 2021年2月19日学习笔记 【椭圆】 div{ background:#fb3; width: 200px;...
    0清婉0阅读 2,118评论 0 2
  • 本文是针对刚学编程的小白,都是一些基础知识,如果想了解更多深层一点的东西,欢迎移步本人博客!! 博客地址 点击跳转...
    西巴撸阅读 557评论 0 0
  • w3cplus中说:渐变是两种或多种颜色之间的平滑过渡。在创建渐变的过程中,可以指定多个中间颜色值,这个值称为色标...
    0清婉0阅读 831评论 0 1
  • 1.使用渐变 因为渐变可以接受一个角度,比如45deg作为方向,而且色标的位置信息也可以是绝对的长度值,不受容器尺...
    0清婉0阅读 1,321评论 0 1
  • 推荐指数: 6.0 书籍主旨关键词:特权、焦点、注意力、语言联想、情景联想 观点: 1.统计学现在叫数据分析,社会...
    Jenaral阅读 5,753评论 0 5