1

I have the following HTML that uses a flex container to house two divs, one containing an image (on the left) and the other one has some text:

<!DOCTYPE html>
<html>
<body>

<div id="wrapper" style="display:flex; background:pink;">

    <div id="image_div">
        <img src="http://i.imgur.com/MvnfA1U.png">
    </div>

    <div id="number_list">
        <h3>One</h3>
        <h3>Two</h3>
        <h3>Three</h3>
        <h3>Four</h3>
        <h3>Five</h3>
        <h3>Six</h3>
        <h3>Seven</h3>
    </div>

</div>
</body>
</html>

Which results in the following:

enter image description here

How do I get the image to increase in size and take the full height of its (pink) container, while:

  1. Keeping the image adjacent to the text (only pushing as far right as it needs to go)
  2. Maintaining the image's aspect ratio
  3. Without cutting off part of the image
  4. Without having text overlap the image
  5. Keeping it generic (eg no specifying pixel lengths)

Thanks

dismantle
  • 91
  • 2
  • 6

1 Answers1

-2

    <!DOCTYPE html>
    <div id="wrapper" style="display:flex; background:pink;justify-content:space-between;">
    
        <div id="image_div">
            <img src="http://i.imgur.com/MvnfA1U.png" style="height:100%;">
        </div>
    
        <div id="number_list" style="width:50%">
            <h3>One</h3>
            <h3>Two</h3>
            <h3>Three</h3>
            <h3>Four</h3>
            <h3>Five</h3>
            <h3>Six</h3>
            <h3>Seven</h3>
        </div>
    
    </div>
Manu Tyagi
  • 11
  • 3