首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JQ:dotdotdot ::展开带有浮动子的父级(高度)

JQ:dotdotdot ::展开带有浮动子的父级(高度)
EN

Stack Overflow用户
提问于 2014-10-09 02:53:24
回答 1查看 352关注 0票数 1

场景:我一直在使用一个jquery脚本,它允许我为多个嵌套的浮动列显示/隐藏Jquery:dotdotdot的内容。

div.featureWrap问题:现在展开时,浮动内容与div.feature和容器的底部边框重叠。我已经尝试过强制div元素包含带溢出的浮动:隐藏,but...no运气。

div.featureWrap所期望的结果:i希望选择的div.feature和容器分别展开/折叠。

我相信这很简单,但是.我刚开始和JS合作。这是破坏需要发生的事情吗?我看到div.css(“最大高度”,“”).

任何帮助都将不胜感激!

见jsfiddle:http://jsfiddle.net/cpardon/tt5htr3s/11/

Jquery:

代码语言:javascript
复制
$(function () {
    $(".desc").dotdotdot({
        ellipsis: '...',
        after: 'a.more',
        wrap: 'word',
        fallbackToLetter: true,
        callback: dotdotdotCallback,
        watch: 'window',
        height: null
    });
    $(".desc").on('click', 'a', function () {
        if ($(this).text() == "More") {
            var div = $(this).closest('.desc');
            div.trigger('destroy').find('a.more').hide();
            div.css('max-height', '');
            $("a.less", div).show();
        } else {
            $(this).hide();
            $(this).closest('.desc').css("max-height", "60px").dotdotdot({
                after: "a.more",
                callback: dotdotdotCallback
            });
        }
    });

    function dotdotdotCallback(isTruncated, originalContent) {
        if (!isTruncated) {
            $("a", this).remove();
        }
    }
});

CSS:

代码语言:javascript
复制
.left {float:left;}
.clearboth {clear:both;}
#featureWrap {width:100%;}
#featureWrap .feature {width:100px;margin:0 5px;border:1px solid #CCC;padding:7px;}
#featureWrap .feature .title {color:#777;padding:12px 0;font-size:20px;}
#featureWrap .feature .desc {font-size:12px;line-height:19px;color:#555;max-height:60px;}
#featureWrap .feature .desc a {color: rgb(224, 86, 40);text-decoration: none;}
#featureWrap .feature .desc a:hover {color: #666;text-decoration: none;}
#featureWrap .feature .desc a.less {display: none;}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-09 03:31:51

更改第15行:

代码语言:javascript
复制
div.css('max-height', '');

代码语言:javascript
复制
div.css('max-height', 'none');

小提琴

您的原始代码将尝试将样式与''内联,后者依次试图清除最大高度,但您的max-height: 60px;样式是在CSS中设置的。通过放置一个max-height: none;,它具有更高的优先级

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26269541

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档