In MFC in CDHtmlDialog,how to vertically and horizontally center align img inside div?

abc abc 351 Reputation points
2021-08-27T17:57:18.457+00:00

Hi

I am using windows 10 and VS2019. In MFC in CDHtmlDialog, how to vertically and horizontally center align img inside div?

CDHtmlDialog isnot supporting display:flex and display:table-cell.

My HTML


<TABLE WIDTH="100%" cellspacing=0 cellpadding=0 >

    <tr>
    <td>
      <div class="parent">
        <img class="im" src="https://d30y9cdsu7xlg0.cloudfront.net/png/255751-200.png" />
     <img class="im" src="https://d30y9cdsu7xlg0.cloudfront.net/png/255751-200.png" />
    </div>
</td>
</td>
<table>

My CSS style


.parent {
     display:inline;
     vertical-align:middle;
     height:100px;
     background: red;
     width:300px;
    }

    .im {
      height: 50px;
    }
Developer technologies | C++
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 122.6K Reputation points
    2021-08-27T19:09:46.597+00:00

    Since you use absolute sizes, then try this table:

    <table WIDTH="100%" cellspacing=0 cellpadding=0>
        <tr>
            <td>
                <div class="parent" style="text-align: center">
                    <span style="position: relative; top: 25px;" ">
                        <img class="im" src="https://d30y9cdsu7xlg0.cloudfront.net/png/255751-200.png" />
                        <img class="im" src="https://d30y9cdsu7xlg0.cloudfront.net/png/255751-200.png" />
                    </span>
                </div>
            </td>
        </tr>
    </table>
    
    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.