0

更新:问题似乎是 和 之间的height:13em过渡height:auto。当我将它们都更改em为像素或两者都更改为像素时,它工作正常。

我正在使用一个简单的 jquery 函数来添加和删除一个类并设置一个转换。过渡表现得很奇怪。它在 FF 中不起作用,Safari 和 Chrome 通过折叠高度,然后将其打开到其预定义的 css 高度来给出奇怪的过渡效果。

http://jsfiddle.net/k8gfb/7/

HTML

<div id="site-description-extended" class="site-description-extended">
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.
</div>

<div id="view-more-button" class="view-more-button">    
  <a href="#">
    Click for More
  </a>
</div>

<div id="view-less-button" class="view-less-button">    
  <a href="#">
     Click for Less
  </a>
</div>

JAVASCRIPT

     $(document).ready(function () {
        $(".view-more-button").click(function () {
            $(".site-description-extended").addClass("extend-description");
            $(".view-more-button").hide();
            $(".view-less-button").show();
        });
    });
    $(document).ready(function () {
        $(".view-less-button").click(function () {
            $(".site-description-extended").removeClass("extend-description");
            $(".view-more-button").show();
            $(".view-less-button").hide();
        });
    });

CSS

    .site-description-extended {
        background: url(images/separator-horizontal.png) center bottom no-repeat;
        box-sizing: border-box;
            -ms-box-sizing: border-box;
            -moz-box-sizing: border-box;
            -o-box-sizing: border-box;
            -webkit-box-sizing: border-box;
        clear: both;
        float: left;
        font-size: 12px;
        line-height: 22px;
        padding: 0px 160px 29px;
        text-align: left;
        width: 100%;
        height:12em;
        overflow:hidden;
        transition: all 1s ease;
        -webkit-transition: all 1s ease;
        -moz-transition: all 1s ease;
        -o-transition: all 1s ease;
        }
    .view-more-button {
        text-align:center;
        padding:0;
        margin:0;
        font-size:0.8em;
        text-decoration:none;
    }
    .view-less-button{
        text-align:center;
        padding:0;
        margin:0;
        font-size:0.8em;
        text-decoration:none;
        display:none;
    }
    a, a:hover, a:active, a:visited {
        text-decoration:none;
    }
    .extend-description {
        height:auto !important;
    }
4

0 回答 0