【发布时间】:2010-09-17 23:27:56
【问题描述】:
如何使用 jQuery 更改图像分辨率。我使用 css/php 在正文背景上应用了图像。现在我想将屏幕高度和宽度应用于图像,以便图像在全窗口中显示。 实际上我没有使用重复样式。
使用的代码是:
<style type="text/css">
<?php
global $post;
if ( has_post_thumbnail($post->ID) ) {
$image_id = get_post_thumbnail_id($post->ID);
$bg_src = wp_get_attachment_image_src( $image_id, 'full');
?>
body { background: #000000 url("<?php echo $bg_src[0]; ?>") no-repeat center top fixed !important; }
<?php } else { ?>
body { background: #000000 url("<?php bloginfo('template_directory') ?>/img/bg_img.jpg") no-repeat center top fixed ; }
<?php } ?>
</style>
我使用它获取屏幕高度和宽度,我们无法理解在该图像上实现它的内容。
var p_browserHeight= screen.height;
var p_browserWidth= screen.width;
jQuery('body.archive').css('height',p_browserHeight+'px' );
jQuery('body.archive').css('width',p_browserWidth+'px' );
【问题讨论】:
-
你知道如果你同时改变你会弄乱纵横比吗?如果你只改变宽度,高度将是任何需要的
-
CSS3 最后有一个 background-size 属性。一旦在浏览器中得到广泛支持,将高度/宽度设置为 100% 会更容易。
-
是的。 '在那之前,你需要一种不同的方法。
标签: php javascript jquery html css