php - Wordpress 二十十二全屏响应式背景图片

标签 php css wordpress responsive-design fullscreen

我刚刚开始使用 Wordpress Twenty Twelve 子主题进行前端开发。

我想让我的背景全屏响应。 我关注了这篇文章:Full-screen responsive background image因为这正是我要找的。

但是当我将此 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不存在。 这是我的current website .

求助!没有这个我就无法继续前进而且我落后于计划:( 感谢您的宝贵时间!

最佳答案

有一个很好的 css 方法可以做到这一点:

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

关键是background-size: cover; line - 无论窗口大小如何,它都会调整大小。查看http://www.w3schools.com/cssref/playit.asp?filename=playcss_background-size&preval=cover

关于php - Wordpress 二十十二全屏响应式背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18284446/

相关文章:

html - CSS 显示调整大小和裁剪的图像

javascript - 在设置更新时更新自定义 slider

MYSQL:使用2个表的ID进行选择过滤

php - 在 PHP 和 MySQL 中使用 cookie——好的做法?

html - CSS nth-of-type 不工作

php - Free Radius + Captive Portal + MySql 未收到有效的 RADIUS 响应

html - 具有列反向影响同级内联柔性容器对齐的内联柔性容器

php - 在 localhost xampp os x 上建立数据库连接时出错

php - htaccess Symfony2 将所有 *.php 页面(除了 app.php)重定向到 app.php

php - store 函数不将数据保存到数据库