如何在悬停时使用css3过渡为td?

时间:2012-01-17 19:26:50

标签: css3 hover transition css-transitions

我有一个td元素是一个链接(使用span来覆盖) 我面临着如何为此做出悬停过渡效果的问题。 我想要的是在td元素上突然高出它的当前位置。

这是我的HTML代码:

<td  class='page'>
<h2><a class='grouped_elements' href='#data111' >
<span>text</span>
</a></h2>
</td>

这就是css:

    .page {

    width: 195px;
    height: 150px;
    position: relative;
    margin: auto;
    padding: 15px 0;
    color: #212121;


    -webkit-border-bottom-left-radius: 20px 500px;
    -webkit-border-bottom-right-radius: 500px 30px;
    -webkit-border-top-right-radius: 5px 100px;

    -moz-border-radius-bottomleft: 20px 500px;
    -moz-border-radius-bottomright: 500px 30px;
    -moz-border-radius-topright: 5px 100px; 

    border-radius-bottomleft: 20px 500px;
    border-radius-bottomright: 500px 30px;
    border-radius-topright: 5px 100px;

    background: #fcf59b;
    background: 
        -webkit-gradient(
            linear,
            left top, left bottom,
            from(#81cbbc),
            color-stop(2%, #fcf59b)
        );

    background: 
        -moz-repeating-linear-gradient(
            top,
            #fcf59b,
            #fcf59b 38px,
            #81cbbc 40px
        );

    background: 
        repeating-linear-gradient(
            top,
            #fcf59b,
            #fcf59b 38px,
            #81cbbc 40px
        );      

    -webkit-background-size: 100% 40px;

    -webkit-box-shadow: 0 2px 10px 1px rgba(0,0,0,.2); 
    -moz-box-shadow: 0 2px 10px 1px rgba(0,0,0,.2); 
    box-shadow: 0 2px 10px 1px rgba(0,0,0,.2); 

    -webkit-transition: margin 0.5s ease-out;
    -moz-transition: margin 0.5s ease-out;
    -o-transition: margin 0.5s ease-out;


}
.page:before {
    content: ' ';
    background: url(tape.png) no-repeat;
    width: 129px;
    height: 38px;
    position: absolute;
    top: -15px;
    left: 40%;
    display: block;
}
.page a {
 text-decoration:none;
}
.page span {
  position:absolute; 
  width:100%;
  height:100%;
  top:0;
  left: 0;
  z-index: 1;
}

.page:hover {

 margin-top: 10px;
}

帮助,我需要一个人吗?

1 个答案:

答案 0 :(得分:0)

您不能在表格单元格或行上应用除静态之外的边距或position,因此即使您没有使用过渡也无法使用。

你需要......

<td>
  <div class="page">
    <h2>
      <a class='grouped_elements' href='#data111' >
          <span>text</span>
      </a>
    </h2>
  </div>
</td>

从那里调整。