I have an image that should be fit with the container below the sub-1 class according to the below code.
I tried object-fit:cover property but it did not work It shows browser’s own image part.I want to show certain part of the image.how can I do that.
`<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.container{
display: flex;
border: 1px solid red;
}
.col-1{
display: flex;
flex-direction: column;
width: 40%;
}
.sub-1{
border: 1px solid blue;
}
.sub-2{
border: 1px solid blue;
height: 100%;
}
</style>
</head>
<body>
<div class="container">
<div class="col-1">
<div class="sub-1">
some text
</div>
<div class="sub-2">
<img src="image.png">
image should be here
</div>
</div>
<div class="col-2">
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit.
Voluptatibus quae
hic autem enim sunt deserunt officia architecto dolorum quam.
</p>
<a href="#">some link</a>
</div>
</div>
</body>
</html>
2
Answers
object fit only change image size in an Specified width and height size that’s mean you shoud change image size to what every size you like
for example if your image is horizontal and you set image width and height to 400px it will changed to cover width and height so it will zoom a little bit
just change your image size (if your image size covered to container size you should change container size )
Is this the effect you want?