幅と高さを知らずに div を垂直方向と水平方向に揃えるにはどうすればよいですか?
例:
<body style="padding:0px; margin:0px;">
<div id="FancyOverlay" style=" position:fixed; width:100%; height:100%; background-color:green;">
<div id="Grandparents" style="position:absolute; left:50%; z-index:1;">
<div id="Parent" style="position: relative; left:-50%; padding:10px; border:1px solid black;">
<img id="fancyImage" src="https://appharbor.com/assets/images/stackoverflow-logo.png"></img>
</div>
</div>
</div>
</body>
このコードをテストして、私がやろうとしていることを確認してください。#保護者は画面の中央にいる必要があります。すでに水平方向に配置しましたが、垂直方向に機能させることができません。
ところで:画像の幅と高さはわかりません。これは単なる例です。