图像高度宽度问题

时间:2010-09-17 14:21:42

标签: php javascript jquery html css

如何使用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' );

2 个答案:

答案 0 :(得分:1)

您可以在身体标记之后添加此html:

<img src='img/bg_img.jpg' style='display:none;' id='image_hidden'/>

使用jquery

获取此图像的with / height

答案 1 :(得分:0)

您无法使用css更改背景图像的大小。

相关问题