Twitter Bootstrap Responsive Background-Image inside Div

后端 未结 9 1257
醉梦人生
醉梦人生 2020-12-13 03:15

How i can modify #bg image so it would be responsive, resizable and proportional in all browser?

HTML:

 
相关标签:
9条回答
  • 2020-12-13 04:19

    This should work

    background: url("youimage.png") no-repeat center center fixed;
    -webkit-background-size: 100% auto;
    -moz-background-size: 100% auto;
    -o-background-size: 100% auto;
     background-size: 100% auto;
    
    0 讨论(0)
  • 2020-12-13 04:20

    The way to do this is by using background-size so in your case:

    background-size: 50% 50%;
    

    or

    You can set the width and the height of the elements to percentages as well

    0 讨论(0)
  • 2020-12-13 04:21

    You might also try:

    background-size: cover;
    

    There are some good articles to read about using this CSS3 property: Perfect Full Page Background Image by CSS-Tricks and CSS Background-Size by David Walsh.

    PLEASE NOTE - This will not work with IE8-. However, it will work on most versions of Chrome, Firefox and Safari.

    0 讨论(0)
提交回复
热议问题