如何显示全高的背景图像? [英] How to show full height background image?

查看:146
本文介绍了如何显示全高的背景图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有1200像素高度的照片类型(而不是横向)的背景图像与979px宽。我想将它设置为浮动左,显示100%完整的图像高度固定,无需/向下滚动(不考虑内容长度)。

I have a photo type (not landscape) background image with 979px Width by 1200px Height. I would like to set it to float left and show 100% full image height fixed without the need to scroll up/down (regardless of content length).

这是我的CSS code,但无法正常工作。

This is my CSS code but not working.

img, media {
  max-width: 100%;
}


    body 
    {
        background-color: white;
        background-image: url('../images/bg-image.jpg');
        background-size: auto 100%;
        background-repeat: no-repeat;
        background-position: left top;
    }

请指教。

感谢。

HC。

推荐答案

您可以用$ C $做c您有。你需要确保 HTML 设置为100%的高度,虽然

You can do it with the code you have. You need to ensure that the html and body are set to 100% height though

http://jsfiddle.net/kevinPHPkevin/a7eGN/

html, body {
    height:100%;
} 
body 
    {
        background-color: white;
        background-image: url('http://www.canvaz.com/portrait/charcoal-1.jpg');
        background-size: auto 100%;
        background-repeat: no-repeat;
        background-position: left top;
    }

这篇关于如何显示全高的背景图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆