css - 我需要什么代码才能只有这些按钮之一?

标签 css button hover css-selectors

我只想使用右侧的按钮:

http://cssdeck.com/item/preview/343/css-text-switcher

我需要什么代码才能只拥有该按钮而不是第一个按钮?由于所有后代选择器,我正在苦苦挣扎..

最佳答案

HTML(仅限相关代码):

<nav>
  <ul>
    <li>
      <a href="#">
        <span>Want to learn more?</span>
        <span>Send us an email :)</span>
      </a>
    </li>
  </ul>
</nav>​

CSS(仅限相关代码):

ul {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 320px;
    height: 30px;
    margin: -15px 0 0 -160px;
    list-style: none;
    font: .75em "lucida grande", arial, sans-serif;
}

a {
    position: absolute;
    width: 150px;
    height: 100%;
    text-decoration: none;
}

a span {
    position: absolute;
    width: 100%;
    text-align: center;
    line-height: 30px;
}

li a {
    overflow: hidden;
    right: 0;
    color: #fff;
}

li span {
    -webkit-transition: top .3s ease-out;
    -moz-transition: top .3s ease-out;
    -o-transition: top .3s ease-out;
    -ms-transition: top .3s ease-out;
    transition: top .3s ease-out;
}

li span:first-child {
    background: #333;
    top: 0;
}

li span + span {
    background: #39f;
    top: 30px;
}

li a:hover span:first-child {
    top: -30px;
}

li a:hover span + span {
    top: 0;
}

JSFiddle

关于css - 我需要什么代码才能只有这些按钮之一?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11059518/

相关文章:

jquery - 处理触摸设备和悬停效果

html - 悬停效果 buggy

html - 不能悬停第二个

android - 布局按钮,使每个按钮平均分配空间

swift - 在 Swift 中创建一个转到另一个类的按钮

java - 安卓 : Cannot cast from View to Button

css - 多个背景图像在 IE8 和 IE7 中不起作用

html - CSS transform rotate 在 Chrome 上运行异常

html - 具有可变填充的 CSS 底部对齐

javascript - 在页面上放大两次后 Canvas 覆盖消失