Edit This Code:
<!DOCTYPE html>
<html>
<head>
<style>.div1 {
    border: 1px solid black;
    height:150px;
    width:180px;
    background:url("img_flwr.gif");
    background-repeat: no-repeat;
}


.div2 {
    border: 1px solid black;
    height:150px;
    width:180px;
    background:url("img_flwr.gif");
    background-repeat: no-repeat;
    background-size: contain;
}


.div3 {
    border: 1px solid black;
    height:150px;
    width:180px;
    background:url("img_flwr.gif");
    background-repeat: no-repeat;
    background-size: cover;
}

</style>
</head>
<body>

<p>Original image:</p>
<div class="div1">
<p>Lorem ipsum dolor sit amet.</p>
</div>

<p>Using the "contain" keyword:</p>
<div class="div2">
<p>Lorem ipsum dolor sit amet.</p>
</div>

<p>Using the "cover" keyword:</p>
<div class="div3">
<p>Lorem ipsum dolor sit amet.</p>
</div>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy