I am currently facing an issue with centering images within multiple nested div elements. Each parent div contains two child divs, each of which is 300 pixels wide. I need to display images in the center of each of these child divs, regardless of their size - if the image is smaller than 300 pixels, it should be centered, and if it is 300 pixels, it should automatically fill up the entire space. Can anyone provide a solution for this?
Below is the code snippet:
<div style="margin-top:10px;height: 300px;width: 600px;background: whitesmoke">
<div style="float:left;width: 300px;height: 300px;">
<img class="" src="images/productImages/medium/<?php echo $product1['product_image']?>" alt="image_01" width="" height="" />
</div>
<div style="float:right;width: 300px;height: 300px;">
<?php if(!empty($product2)) { ?>
<img class="" src="images/productImages/medium/<?php echo $product2['product_image']?>" alt="image_02" width="" height="" />
<?php } ?>
</div>
</div>