[英]Fancybox description box maintaining size upon window re-size
我在fancybox的弹出图像旁边有一个描述框,但是从上方重新调整窗口大小(在jsfiddle中尝试)时,图像会适应更改并减小尺寸,但是描述框保持其大小。 我正在尝试为描述框提供与图像相同的高度,同时在与图像平行调整窗口大小时减小尺寸。 请帮忙。
JSFIDDLE: http : //jsfiddle.net/tqnk7e3f/4/
HTML:
<a caption="<h2>Image Header</h2><p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>" rel="Sold" class="fancybox" data-fancybox-group="thumb1" href="http://fancyapps.com/fancybox/demo/4_b.jpg"><img src="http://fancyapps.com/fancybox/demo/4_s.jpg" alt="" /></a>
<a class="fancybox hidden" data-fancybox-group="thumb1" href="http://fancyapps.com/fancybox/demo/3_b.jpg"><img src="http://fancyapps.com/fancybox/demo/3_s.jpg" alt="" /></a>
<a class="fancybox" data-fancybox-group="thumb2" href="http://fancyapps.com/fancybox/demo/2_b.jpg"><img src="http://fancyapps.com/fancybox/demo/2_s.jpg" alt="" /></a>
<a class="fancybox hidden" data-fancybox-group="thumb2" href="http://fancyapps.com/fancybox/demo/1_b.jpg"><img src="http://fancyapps.com/fancybox/demo/1_s.jpg" alt="" /></a>
CSS:
.hidden {
display: none;
}
.fancybox-title {
right:auto;
height:auto;
left:-260px;
margin-bottom:auto;
/* CHANGES */
top: 0;
}
.fancybox-title .child {
height: auto;
white-space:normal;
text-align:left;
height:470px;
padding:0 20px;
max-width:200px;
margin-right:auto;
border-radius:0;
}
.fancybox-title .child h2 {
font-size:140%;
line-height:1.5;
margin-top:20px;
margin-bottom:15px;
}
.fancybox-title .child p {
margin-bottom:30px;
}
JQUERY:
$('.fancybox').fancybox({
prevEffect : 'fade',
nextEffect : 'fade',
padding:0,
closeBtn : true,
arrows : true,
nextClick : true,
helpers : {
title : { type : 'outside' }
},
helpers : {
thumbs : {
width : 80,
height : 80
}
},
beforeLoad: function() {
this.title = $(this.element).attr('caption');
}
});
我会尝试找出您要寻找的内容并了解问题所在。 对我来说,最好的解决方案就是这个 。 我将解释所有问题:1.如果将窗口调整为小尺寸,文本将无法包含在黑色div内。 2.当您在大窗口中打开它时,它看起来很奇怪,底部大小留有空白。
这是我对您的代码所做的更改:
.fancybox-title .child
{
height: auto;
white-space:normal;
text-align:left;
/* height:470px; - Remove static height :) */
padding:0 20px;
max-width:200px;
margin-right:auto;
border-radius:0;
}
让我知道是否有帮助:)
编辑
好的,这是我的编辑 。 没有jQuery ,基于其他元素的动态高度是不可能的,所以我添加了一个简单的函数:
$( window ).resize(function() {
imageHeight = $('.fancybox-inner').height();
$('.fancybox-title').height(imageHeight);
});
获取图像高度并基于其设置文本容器高度。 为了使它工作,您还需要在CSS中更改以下几件事:
.fancybox-title {
right:auto;
height:auto; /* This container will now set it height to image height */
left:-260px;
margin-bottom:auto;
top: 0;
}
.fancybox-title .child {
white-space:normal;
text-align:left;
padding:0 20px;
max-width:200px;
margin-right:auto;
border-radius:0;
height:100%; /* Leave it inside so it must have the same size */
}
等待您的批准:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.