使用CSS3过渡动画的有序列表中的选择器

时间:2014-07-09 12:13:55

标签: css list css-selectors transitions

我整理了以下使用过渡的有序列表。基本上在前三个li元素的底部有一个从浅灰色到深灰色的边框底部动画。现在我想要的是修改这种颜色并使它以三种不同的颜色显示。我已经尝试过跨越和课程,但没有成功。您是否可以根据给定的代码澄清我是如何触发此行为的?

 <div id="list">
  <ul>
    <li class="1"><a href="#sectionportfolio">No hacemos uso de cualquier de los componentes prefabricados o mezclas preparadas.</a></li>
    <li class="2"><a href="#sectionportfolio">Una alta calidad en la compra de los ingredientes y la preparación es nuestra principal prioridad.</a></li>
    <li class="3"><a href="#sectionportfolio">Todos nuestros productos se hacen con amor y se han inspirado en recetas familiares.</a></li>
    <li class="4"><a href="#sectionportfolio">Queremos que nuestros clientes estén satisfechos. Si alguna vez tiene motivo de queja, le pedimos que nos devuelva su compra tan pronto como sea posible en nuestra tienda.</a></li>
  </ul>
</div>

#list {
  width: 100%;
  text-align:center;
}

#list ul {
  list-style-type: none;
  margin: 0;
  padding-bottom: 0;
}

#list ul li {
  font: 200 14px/1.5 'oswaldlight';
  border-bottom: 1px solid #ccc;
  padding:30px 0;
  -webkit-transition: border-bottom 1.0s ease, border-bottom 1.4s ease, padding-top 1.0s ease, padding-bottom 1.0s ease, font-size 0.7s ease, background-color 0.3s ease, color 1.0s ease;
  -moz-transition: border-bottom  1.0s ease, border-bottom 1.4s ease, padding-top 1.0s ease, padding-bottom 1.0s ease, font-size 0.7s ease, background-color 0.3s ease, color 1.0s ease;
  -o-transition: border-bottom 1.0s ease, border-bottom 1.4s ease, padding-top 1.0s ease, padding-bottom 1.0s ease, font-size 0.7s ease, background-color 0.3s ease, color 1.0s ease;
  -ms-transition: border-bottom 1.0s ease, border-bottom 1.4s ease, padding-top 1.0s ease, padding-bottom 1.0s ease, font-size 0.7s ease, background-color 0.3s ease, color 1.0s ease;
  transition: border-bottom 1.0s ease, border-bottom 1.4s ease, padding-top 1.0s ease, padding-bottom 1.0s ease, font-size 0.7s ease, background-color 0.3s ease, color 1.0s ease;
  border-spacing:0;
  cursor:crosshair;

}

#list ul li:hover {

  border-bottom: 4px solid #858585;
  padding:40px 0px 5px 0x;
  border-spacing:0;
  font-size: 30px;
  color: #454545;
  cursor:pointer;
}


#list ul li:last-child {
  border: none;
}

#list li a {
  text-decoration: none;
  color: #888;
  text-align:center;
}


#list li a:hover {
    cursor:pointer;}

1 个答案:

答案 0 :(得分:1)

我刚刚使用:nth-child(),这是你想要的吗?

#list ul li:hover {
  padding:40px 0px 5px 0x;
  border-spacing:0;
  font-size: 30px;
  color: #454545;
  cursor:pointer;
}

#list ul li:nth-child(1):hover {
  border-bottom: 4px solid red;    
}

#list ul li:nth-child(2):hover {
  border-bottom: 4px solid blue;    
}

#list ul li:nth-child(3):hover {
  border-bottom: 4px solid green;    
}

JSFIDDLE