Laurentz
8
Q:

scale an image css

<!DOCTYPE html> 
<html>  
    <head>  
        <title>cell padding</title>  
        <style>  
            .gfg { 
                width:auto; 
                text-align:center; 
                padding:20px; 
            } 
            img { 
                width: 100%; 
                height: 100%; 
                object-fit: contain; 
            } 
        </style>  
    </head>  
    <body>  
        <div class = "gfg"> 
                <p id="my-image"><img src= 
"https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-17.png"> 
            </p> 
        </div> 
    </body>  
</html>                     
3
.container {
  width: 50%;
  height: 200px;
  overflow: hidden;
}

.container img {
  max-width: 100%;
  height: auto;
  display: block;
}
-1

New to Communities?

Join the community