san*_*zer 34 css firefox internet-explorer max responsive-design
因此,我试图尽可能大地显示图像,而不会在任何屏幕尺寸上进行裁剪.这意味着,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 -->
Run Code Online (Sandbox Code Playgroud)
我不会比IE9更老,但理想情况下想服务一切.但是只要我能为IE9 +和Firefox服务,我就会很高兴.
哦,顺便说一下 - Firefox中的Inspector告诉我该width:100%
规则正在被遵循,但显然不是.
提前谢谢了!
Bor*_*sky 53
你有max-width: 100%
,但100%的是什么?父母的宽度,对吗?但是父级是一个内联块(使用class ="sponsor"),其宽度未设置,因此其宽度取决于子级,特别是子级的首选宽度.
CSS样式中未定义此样式的布局.特别地,在这种情况下,孩子的固有宽度取决于父母的宽度,而父母的宽度又取决于孩子的固有宽度.有关规范文本,请参见http://www.w3.org/TR/CSS21/visudet.html#shrink-to-fit-float,并注意所有"未定义"位.
我建议给你<div class="sponsor">
一个宽度.我认为应该处理这个问题.
atw*_*tor 16
我的修复是双重的.当没有其他建议时,它工作.它仅使用针对FF的定位,较旧的width: 100%
修复以及其他实验属性.
为了让它工作,我做了以下事情:
@-moz-document url-prefix() {
/* Firefox doesn't respect max-width in certain situations */
img { width: 100%; max-width: -moz-max-content; }
}
Run Code Online (Sandbox Code Playgroud)
魔术子弹是实验-moz-max-content
值.结合使用width: 100%
,它使FF表现得像Safari/Chrome的max-width: 100%;
设置.
我从以下来源找到了这个:
http://ss64.com/css/max-width.html
归档时间: |
|
查看次数: |
44762 次 |
最近记录: |