【问题标题】:css transform rotate flickering/not workingcss变换旋转闪烁/不工作
【发布时间】:2020-09-01 17:04:06
【问题描述】:

我遇到了这个问题,我试图在悬停时旋转这个 div,但是当我悬停时,它尝试悬停,但随后又回到正常位置。能否请你帮忙? 这是我的小提琴:https://jsfiddle.net/Lcb7okfn/

.section-tours{
  background-color:pink;
  padding:5rem 0 50rem 0;

}
.center-text{
  background-color:blue;
  padding:30px 0;

}

.col-1-of-3{
  width: calc((100%-20px)/3);

  }

.card{
  background-color: orange;
  height:15rem;
  transition: all .8s;
  perspective: 1000px;
  -moz-perspective: 1000px;
}
    .card:hover{
      transform: rotateY(180deg); 
}

【问题讨论】:

    标签: css css-transforms


    【解决方案1】:

    将悬停应用到父元素,并将透视声明移动到父元素:

    .section-tours {
      background-color: pink;
      padding: 5rem 0 50rem 0;
    }
    
    .center-text {
      background-color: blue;
      padding: 30px 0;
    }
    
    h2 {
      padding: 0;
      margin: 0;
    }
    
    .col-1-of-3 {
      width: calc((100%-20px)/3);
      perspective: 1000px;
    }
    
    .card {
      background-color: orange;
      height: 15rem;
      transition: all .8s;
    }
    
    .col-1-of-3:hover .card {
      transform: rotateY(180deg);
    }
    <section class="section-tours">
      <div class="center-text">
        <h2>
          Most popular tours
        </h2>
      </div>
      <div class="row">
        <div class="col-1-of-3">
          <div class="card">
            <div class="card class_side">
              TEXT
            </div>
    
          </div>
        </div>
        <div class="col-1-of-3">
    
        </div>
        <div class="col-1-of-3">
    
        </div>
      </div>
    </section>

    【讨论】:

    • 谢谢你的回答,为什么文字没有向后显示?
    猜你喜欢
    • 1970-01-01
    • 2021-02-14
    • 1970-01-01
    • 2015-03-30
    • 1970-01-01
    • 2019-02-06
    • 2016-12-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多