工作示例
我想我已经解决了兼容性问题并将最大高度设置为 300 像素,并为 IE6 提供了解决方法。
JS:
$(document).ready(function () {
$('.popup-with-zoom-anim').magnificPopup({
type: 'inline',
fixedContentPos: false,
fixedBgPos: true,
overflowY: 'auto',
closeBtnInside: true,
preloader: false,
midclick: true,
removalDelay: 300,
mainClass: 'my-mfp-zoom-in'
});
});
// Handles the resize event
$(window).resize(fn_resizeImage);
$('.popup-with-zoom-anim').click(fn_resizeImage);
// Resizes the content2 to fit with image height
function fn_resizeImage() {
var imgHeight = $('div.image_container > img').outerHeight(true);
var cnt1Height = $('div.content > div.content1').outerHeight(true);
var cnt2 = $('div.content > div.content2').outerHeight(imgHeight - cnt1Height);
}
CSS:
img {
width: 300px;
}
.view_container {
max-height:100%;
max-width: 850px;
_width:expression(this.scrollWidth > 850 ?"850px" :"auto");
/* sets max-width for IE6 */
margin: 20px auto;
background-color: #1C1C1C;
padding: 0;
line-height: 0;
border: 1px solid red;
}
.image_container, .content {
width: 50%;
float: left;
}
.image_container img {
max-height:300px;
_height:expression(this.scrollWidth > 300 ?"300px" :"auto");
/* sets max-width for IE6 */
max-width: 100%;
_width:expression(this.scrollWidth > 850 ?"850px" :"auto");
/* sets max-width for IE6 */
}
.image_container {
text-align: center;
}
.content1, .content2 {
background-color: #fff;
padding: 1em;
}
.content {
line-height: 1.231;
}
.content2 {
height: 300px;
overflow-y: scroll;
}
#small-dialog {
max-width: 850px;
_width:expression(this.scrollWidth > 850 ?"850px" :"auto");
/* sets max-width for IE6 */
margin: 20px auto;
background-color: #1C1C1C;
padding: 0;
line-height: 0;
border: 1px solid red;
}
@media (min-width: 1px) and (max-width: 638px) {
.image_container, .content {
width: auto;
float: none;
clear: both;
}
.image_container img {
max-height:150px;
max-width:150px;
_height:expression(this.scrollWidth > 150 ?"150px" :"auto");
/* sets max-width for IE6 */
_width:expression(this.scrollWidth > 150 ?"150px" :"auto");
/* sets max-width for IE6 */
}
}