我的目标:
我想要实现的是,我们在页面上有一些类别列表,但是这个列表的数量是未知的。描述的长度也可能各不相同,但我们希望整个页面看起来统一。因此,我们使用dotdotdot插件在段落中添加省略号。当你将鼠标悬停在项目上时,应该会展开说明并显示完整的文本。
我希望悬停的内容能够浮动或覆盖下面的任何内容。由于我的布局中存在某些项(请参见下面的说明),我的sccontainer元素没有设置高度。它是根据内容动态调整的,但有一个最大高度。
当我在悬停事件中将高度更改为AUTO时(这会导致文本向下流动并显示所有内容),我会失去sccontainer元素的背景。
一些相关的CSS:
.sccontainer { width: 280px; zoom: 1; float: left; margin: 5px 10px; padding: 0; border: 1px solid #8697a1; -moz-border-radius: 5px; border-radius: 5px; -moz-box-shadow: 0 0 6px #777; -webkit-box-shadow: 0 0 6px #777; box-shadow: 0 0 6px #777; -ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=6, Direction=90, Color='#777777')"; filter: progid:DXImageTransform.Microsoft.Shadow(Strength=6, Direction=90, Color='#777777'); position: relative; background: #fff url(http://imagecss.com/images/background.jpg) repeat-x left top; }
.sccontainer .parent { position: absolute; width: 270px; }
.sccontainer .image { margin: 5px; float: left; }
.sccontainer .image img { width: 48px; }
.sccontainer .icon { margin: 0; }
.sccontainer p { margin: 8px; padding: 0; max-height: 145px; }
.sccontainer h1 { line-height: 24px; display: inline-block; vertical-align: middle; width: 200px; height: 48px; padding: 0; margin: 5px 0 0 0; overflow: hidden; }
.sccontainer h1 a { padding: 0; font-size: 24px; color: #fff; font-weight: normal; }
.sccontainer .content { position: relative; height: 210px; padding: 0 5px; font-size: 15px; line-height: 22px; width: 270px; }
.sccontainer a:hover { text-decoration: underline; }
.sccontainer.hover { height: 250px; }
.sccontainer.hover .content { height: auto; }
.sccontainer.hover .content p { min-height: 135px; max-height: none; }
jsFiddle:
这是我目前拥有的jsFiddle版本。如果你将鼠标悬停在蓝色框中的文本上,你就可以看到它的实际效果。由于它有点大,所以我使用了jsFiddle而不是将所有的组件放在代码标签里...
下面这张图片是我想要看到的模型图。5a方法会稍微扩展以显示完整内容,但它将覆盖红线。其他项目都不会发生变化。
注意:对不起,事情有点大。我已经尽量缩小了它的大小。另外,我正在修改一个现有的企业内部网站...它是第三方的,因此我对源代码的控制有限 - 因此使用了表格...:(
我尝试过/研究过的:
我认为问题出在sccontainer项浮动,并且没有指定高度。这就是为什么图片消失的原因。
我有一个版本保留了背景...但sccontainer框没有像我们需要的那样调整大小...文本只是溢出了它...相当丑陋。
我对CSS不够熟悉,无法使所有东西都正常工作。如果需要,我不反对使用jQuery进行更多操作。
我确实尝试过一种版本,大部分使用:hover来处理...但它并没有像jQuery方法那样有效。