【问题标题】:How to use css3 transition on hover for td?如何在悬停时为 td 使用 css3 过渡?
【发布时间】:2012-02-12 14:29:03
【问题描述】:

我有一个 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;
}

帮忙,我需要人吗?

【问题讨论】:

    标签: css hover transition css-transitions


    【解决方案1】:

    您不能在表格单元格或行上应用除静态以外的边距或position,因此即使您不使用过渡,它也不起作用。

    你需要...

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

    并从那里调整。

    【讨论】:

      猜你喜欢
      • 2016-07-23
      • 2012-03-12
      • 2013-07-08
      • 2015-02-09
      • 2013-11-06
      • 2021-01-24
      • 2013-08-22
      • 2014-08-01
      • 1970-01-01
      相关资源
      最近更新 更多