Similar to the attached example, I’m trying to divide a container into two – left side to be of, say, 40% and the right side to be of 60%. in the left side of 40%, I need to upload an image and the image needs to be fit into the 40% without distorting the image (despite whatever sizes of the image is). And the right side (60%) to be entered with text. What I need to achieve is similar to what is given in the attached image.
Please assist. Thank you
enter image description here
I tried using options such as table in HTML. But I do not want lines and borders to be appeared. Then I tried creating a parent Div and then two child div’s within that parent Div. But the image doesn’t get fit to the left portion. It goes completely out of the size
2
Answers
Thanks for the response. kindly check if the codes should be as follows after following your answer;
HTML Structure: The main container (.container) houses two child divs: one for the image (.image-container) and one for the text (.text-container).
CSS Flexbox:
The .container uses display: flex; to establish a flex container, making its children (the image and text containers) flex items.
.image-container and .text-container use the flex property to specify the proportion of space they should take up (40% and 60%, respectively).
The object-fit: cover; property ensures that the image covers its container without being distorted, cropping the excess parts if necessary.