我将帖子/页面特色图像作为内联背景图像。
下面的代码在大多数浏览器上都能完美运行,但不能在 Safari 6.0 及更低版本上运行。
在 Safari 6.0 上,内联样式会跳过background:url('xxx') no-repeat scroll xxx xxx / cover;
并直接转到min-height:(...)
.
background-attachment
也没有显示在 DOM 中。
单个项目站点的示例: http: //skarpsinn.no/prosjekter/oeva。试试前任。Chrome 和 Safari 6.0。这是我的单页 PHP 代码——在其他页面上几乎相同。
<?php if(is_single()):
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
?>
<?php if ( has_post_thumbnail() ) { ?>
<div class="featured_image" style="background: url('<?php echo $image[0]; ?>') no-repeat scroll <?php the_field('bg_vert_posisjon'); ?> <?php the_field('bg_hor_posisjon'); ?> / cover; min-height: 700px; position: relative; width: 100%; background-attachment: <?php the_field('bg_oppforsel'); ?>">
<?php } else { ?>
<div class="no_feature_image"></div>
<?php } ?>
任何输入都会有所帮助!谢谢!