Unresponsive image

1

OnlargerscreenstheimagedoublesandIwantittonothappen.

I'musingthefollowingcode:

background-image:url("../assetsimages/book.jpg");
    background-repeat: repeat;  
    max-width:100%;
    height: auto;

It's still not working

    
asked by anonymous 08.03.2018 / 11:21

3 answers

3

To not repeat use:

background-repeat: no-repeat;

Or

background-size: 100% auto; //Largura e altura respectivamente
    
08.03.2018 / 11:23
3

This code should work. If not, it's because you have some other class overriding yours.

Background documentation: link

Notice that to work you have to determine a height for <body> and for <div>

See below the example covering 50% of the screen without repeating, even the dive having 100%

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}
.bg {
    background-image: url("http://placecage.com/800/600");
    background-repeat: no-repeat;  
    background-size: 50%;
    background-color: aqua;
    background-position: center;
    width: 100%;
    height: 100%;
}
<div class="bg">
    
</div>
    
08.03.2018 / 12:19
0

try this code There is the background-size property: cover; Which causes the background to fill the entire element size

background-image: url("../assetsimages/book.jpg");
background-position:center center;
background-size:cover;
max-width:100%;
height: auto;
    
08.03.2018 / 12:11