Problem with background-attachment



  • There's a problem with a fixed background.

    html:

    <!DOCTYPE html>
    <html>
        <head><head>
        <body>
            <div class="background"></div>
        </body>
    </html>
    

    css:

    html, body{height: 100%}
    body{margin-right: 300px;}
    .background{height: 100%; background: url('http://oi67.tinypic.com/2guecyo.jpg') center top fixed;}
    

    jsfiddle: https://jsfiddle.net/84av76hh/

    Current behaviour:

    Fixed background of element ♪ background ignores the horizontal equilibrium given to him and positiones the relative width of the document.

    desired behaviour:

    It would be desirable that the fixed background be centred on the width of the element to which it was applied rather than on the total width.

    How?



  • I've known the problem for a long time, and I finally get it.

    .background{height: 100%; 
    background: url('http://oi67.tinypic.com/2guecyo.jpg') center top fixed;
    background-position: top right 35%;
    }
    

    The problem is partially solved, but it's not the same, but without the fixed, it's quite strange, but it's still possible to try to div, which will only be used for the background.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2