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

标签 css list css-selectors transition

我整理了以下使用转换的有序列表。基本上在前三个 li 元素的底部有一个从浅灰色到深灰色的边框底部动画。现在我想要的是修改这个颜色,让它出现三种不同的颜色。我已经用 span 和 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;}

最佳答案

我刚刚用了: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

关于css - 使用 CSS3 过渡动画的有序列表中的选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24653417/

相关文章:

Android 在 ListAdapter 中设置 View 可见性

Python:如何将一个列表和一个列表的列表映射在一起

javascript - 在 css 选择器中使用通配符属性不会返回任何匹配项

jQuery .each() 不等于直接在选择器上调用方法?

php - 我应该显示列表的CSS按钮具有提交功能

jquery - 如何让元素在父悬停时显示?

javascript - 如何将新生成的 div 放在另一个 div 旁边?

html - 为什么 Firefox 上的最小高度大于高度?

c# - 将 List<int> 作为查询参数传递给 SQL Server

variables - 创建 Sass mixin 时,我可以使用 :nth-child declaration? 中的变量吗