doubi7346 2013-08-17 02:12
浏览 85
已采纳

Wordpress二十二十全屏响应背景图像

I have just started front-end development with Wordpress Twenty Twelve child theme.

I want to make my background full-screen responsive. I followed from this post: Full-screen responsive background image because it is exactly what I'm looking for.

But when I copy and paste this css code into my 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% */
  }
}

It doesn't work. It feels like img.bg doesn't exist. This is my current website.

Please help! I cannot move on without this and I'm behind schedule :( Thank you for your time!

  • 写回答

2条回答 默认 最新

  • doulang9953 2013-08-17 02:23
    关注

    There's a nice css way of doing this:

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

    The key is the background-size: cover; line - it will resize no matter what the window size. Check it out at http://www.w3schools.com/cssref/playit.asp?filename=playcss_background-size&preval=cover

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100