[英]Image Height Width Problem
如何使用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>
我使用它來獲取屏幕的高度和寬度,我們無法理解在該Image上實現它的方式。
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' );
您可以在body標簽之后添加此html:
<img src='img/bg_img.jpg' style='display:none;' id='image_hidden'/>
並使用jQuery獲取此圖像的高度/高度
您無法使用CSS更改背景圖片的大小。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.