CSS:翻译值不起作用



.arrow中的翻译值在这里似乎没有任何影响。 有人可以解释我为什么

<!doctype html>
<html>
<head>
<style>
.container{
    height:500px;
    width:600px;
}
.header{ height:40px; }
.step{width:194px;float:left; border:1px solid black; height:40px;}
.arrow{display:inline-block;width:25px; height:25px; border-left:1px solid 
 black; border-bottom: 1px solid black;-webkit-transform:translateY(20px); 
 transform:rotate(-135deg);  }
</style>
</head>
<body>
<div class='container'>
    <div class='header'>
      <div class='step'> step 1 <div class='arrow'> </div></div>
      <div class='step'> step 2 <div class='arrow'> </div></div>
      <div class='step'> step 3 <div class='arrow'> </div></div>
    <div class='body'> </div>
</div>

您应该将

这两个添加到相同的 transform 属性中,例如 transform: translateY(20px) rotate(-135deg) ,否则由于 CSS 级联规则,只会考虑最后一个值:

.container {
  height: 500px;
  width: 600px;
}
.header {
  height: 40px;
}
.step {
  width: 194px;
  float: left;
  border: 1px solid;
  height: 40px;
}
.arrow {
  display: inline-block;
  width: 25px;
  height: 25px;
  border-left: 1px solid;
  border-bottom: 1px solid;
  transform: translateY(20px) rotate(-135deg);
}
<div class='container'>
  <div class='header'>
    <div class='step'> step 1 <div class='arrow'> </div></div>
    <div class='step'> step 2 <div class='arrow'> </div></div>
    <div class='step'> step 3 <div class='arrow'> </div></div>
  <div class='body'></div>
</div>

最新更新