Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress Twenty 12全屏响应背景图像_Php_Css_Wordpress_Responsive Design_Fullscreen - Fatal编程技术网

Php Wordpress Twenty 12全屏响应背景图像

Php Wordpress Twenty 12全屏响应背景图像,php,css,wordpress,responsive-design,fullscreen,Php,Css,Wordpress,Responsive Design,Fullscreen,我刚刚开始了Wordpress二十一儿童主题的前端开发 我想让我的背景全屏响应。 我从这篇文章中了解到:因为这正是我要寻找的 但当我将此css代码复制并粘贴到我的style.css中时: img.bg { /* Set rules to fill background */ min-height: 100%; min-width: 1024px; /* Set up proportionate scaling */ width: 100%; height: auto;

我刚刚开始了Wordpress二十一儿童主题的前端开发

我想让我的背景全屏响应。 我从这篇文章中了解到:因为这正是我要寻找的

但当我将此css代码复制并粘贴到我的style.css中时:

img.bg {
  /* Set rules to fill background */
  min-height: 100%;
  min-width: 1024px;

  /* Set up proportionate scaling */
  width: 100%;
  height: auto;

  /* Set up positioning */
  position: fixed;
  top: 0;
  left: 0;
}

@media screen and (max-width: 1024px) { /* Specific to this particular image */
  img.bg {
    left: 50%;
    margin-left: -512px;   /* 50% */
  }
}
它不起作用。感觉好像img.bg不存在。 这是我的

请帮忙!没有这一点,我无法继续前进,我落后于计划:(
谢谢您的时间!

您需要2使用jscript指令。 例如:

        var theWindow        = jQuery(window),
            jQuerybg              = jQuery("#bg"),
            aspectRatio      = jQuerybg.width() / jQuerybg.height();
        function resizeBg() {           
            if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
                jQuerybg
                    .removeClass()
                    .addClass('bgheight');              
            } else {
                jQuerybg
                    .removeClass()
                    .addClass('bgwidth');               
            }

        }

        theWindow.resize(function() {
            resizeBg();
        }).trigger("resize");
var theWindow=jQuery(window),
jQuerybg=jQuery(“#bg”),
aspectRatio=jQuerybg.width()/jQuerybg.height();
函数resizeBg(){
如果((theWindow.width()/theWindow.height())
有一种很好的css方法:

div
{
position: absolute; width: 100%; height: 100%;
background-image:url('smiley.gif');
background-repeat:no-repeat;
background-size:cover;
}

关键是背景尺寸:cover;line-无论窗口大小如何,它都会调整大小。请访问

查看它,谢谢!但我还是太新手,无法理解jscript…如果有人尝试过这个方法并成功了,请重复:)