CSS变换旋转失真

时间:2014-11-13 05:31:04

标签: css3

以下是我的代码

http://liveweave.com/ks0njD

HTML:

<div class="container">
<div class="box1"></div>
<div class="box2"></div>
  </div>

和CSS:

.container {
  width: 300px;
  height: 300px;
  border: 1px solid black;
  backface-visibility: hidden;
    perspective: 1000px;
}
.box1 {
  position: relative;
  width: 100px;
  height: 2px;
  background: black;
  top: 100px;
  left: 200px;
  transform: rotate(45deg);
  transition: .5s;
  backface-visibility: hidden;
    perspective: 1000px;
}
.box2{
  position: relative;
  width: 100px;
  height: 2px;
  background: black;
  top: 100px;
  left: 200px;
  transform: translateY(68px) rotate(-45deg);
  backface-visibility: hidden;

  transition: .5s ease;
    perspective: 1000px;

}
.container:hover .box1{
  transform: rotate(60deg);
  transition: .8s ease;
  backface-visibility: hidden;
}
.container:hover .box2 {
  transform: translateY(84px) rotate(-60deg);
  transition: .8s ease;
  backface-visibility: hiddeni;
}

正如你所看到的,当div旋转时会有轻微的扭曲,无论如何我能让它看起来很完美吗?我尝试使用背面和透视但没有任何区别。

1 个答案:

答案 0 :(得分:0)

@Amer你的意思&#39;看起来很完美&#39;?像这样的东西?

&#13;
&#13;
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<style type="text/css">
.container {
  width: 300px;
  height: 300px;
  border: 1px solid black;
  backface-visibility: hidden;
    perspective: 1000px;
}
.box1 {
  position: relative;
  width: 100px;
  height: 15px;
  background: black;
  top: 112px;
  left: 200px;
  background:#3ac7f2;
  transform: rotate(45deg);
  transition: .5s;
  backface-visibility: hidden;
   perspective: 1000px;
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  border-radius: 10px;
}
.box2{
  position: relative;
  width: 100px;
  height: 15px;
  background: black;
  top: 93px;
  left: 200px;
  background:#3ac7f2;
  transform: translateY(68px) rotate(-45deg);
  backface-visibility: hidden;
  transition: .5s ease;
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  border-radius: 10px;
}
.container:hover .box1{
  background:#09F;
  transform:background .4s ease-in-out;
  transform: rotate(-45deg);
  transition: .8s ease;
  backface-visibility: hidden;
}
.container:hover .box2 {
  background:#09F;
  transform:background .4s ease-in-out;
  transform: translateY(68px) rotate(45deg);
  transition: .8s ease;
  backface-visibility: hiddeni;
}
</style>
</head>
<body>
<div class="container">
<div class="box1"></div>
<div class="box2"></div>
  </div>
</body>
</html>
&#13;
&#13;
&#13;