【发布时间】:2013-01-11 02:27:03
【问题描述】:
所以我试图在不裁剪任何屏幕尺寸的情况下显示尽可能大的图像。这意味着height: 100%; width: auto 中的landscape 和width: 100%; height: auto 中的portrait。
我提供的图像大到足以填满视网膜 iPad,因此几乎每个屏幕尺寸都会缩小图像。除了横向模式下的 Internet Explorer 和 Firefox 之外,它在所有浏览器和方向上都能做到这一点,这使得它们对于几乎每个屏幕来说都太大了。请注意,这仅适用于横向。
相关代码如下:
<style type="text/css">
#container {position:absolute; top:0; left: 0; right: 0; bottom:0; display: block;}
#content {
text-align: center;
margin: 0px;
font-size:0;
position: absolute;
top:0; left: 0; right: 0; bottom: 0
}
#content:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -0.25em;
}
.sponsor {
display: inline-block;
vertical-align: middle;
}
#content img {
max-width: 100%;
width: 100%;
height:auto;
}
@media all and (orientation: landscape) {
#main {
top:0;
display: block;
width: 100%;
height: 100%;
margin:0px auto;
text-align:center;
}
#content img {
height:100%;
width:auto;
max-width:auto !important;
max-height:100%;
display:block;
margin:0 auto;
}
}
</style>
<div id="content">
<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<div title="Click to flip" class="sponsor">
<a href="#" class="img-link">
<img src="<?php echo $image[0]; ?>" alt="" class="feat-1" style="display: block;" />
</a>
<a href="#">
<img src="<?php echo kd_mfi_get_featured_image_url('featured-image-2', 'post', 'full'); ?>" alt="" class="feat-2" style="display: none;" />
</a>
</div><?php endif; ?>
</div><!-- End div #content -->
我对 IE9 之前的版本不太在意,但理想情况下我想为所有内容提供服务。不过,只要我能提供 IE9+ 和 Firefox,我就会很高兴。
哦,顺便说一句 - Firefox 中的 Inspector 告诉我正在遵循 width:100% 规则,但显然不是。
非常感谢!
【问题讨论】:
标签: css internet-explorer firefox responsive-design max