<html>
<head>
    <style>
        .testcase { position: relative; height: 100px; margin: 10px; border: 1px solid black;}
        .container { position: relative; width: 100px; background-color: gray; }
        img { position: absolute; width: 50px; height: 100%; background-color: blue; }
    </style>
</head>
<body>
    <div class="testcase">
        <span class="container"><br>again
        </span>
    </div>
    
    <div class="testcase">
        <span class="container"><img><br>
        </span>
    </div>
    
    <div class="testcase">
        <span class="container">
            <img><br>
        </span>
    </div>
    
    <div class="testcase">
        <span class="container"><img><br><br>
        </span>
    </div>

    <div class="testcase">
        <span class="container">
            <img><br><br><br><br>
        </span>
    </div>
</body>
</html>