Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 绝对定位元件的垂直居中';s儿童没有';行不通_Html_Css_Vertical Alignment - Fatal编程技术网

Html 绝对定位元件的垂直居中';s儿童没有';行不通

Html 绝对定位元件的垂直居中';s儿童没有';行不通,html,css,vertical-alignment,Html,Css,Vertical Alignment,我需要帮助将我的黄色盒子垂直居中 <html> <head> <title></title> </head> <body style="border-collapse: collapse;"> <div style="margin: 100px; width: 100px; height: 200px; background-color: gray; border: 1px solid gray;"&g

我需要帮助将我的黄色盒子垂直居中

<html>
<head>
    <title></title>
</head>
<body style="border-collapse: collapse;">
    <div style="margin: 100px; width: 100px; height: 200px; background-color: gray; border: 1px solid gray;">
        <table style='background-color: white; width: 100%; height: 100%; border-collapse: collapse; vertical-align: top;'>
            <tr>
                <td style='height: 33.33%;'>
                    <div style="position: relative; width: 100%; height: 100%;">
                        <div style="position: absolute; top: -50%; height: 100%; display: table-cell; vertical-align: middle;">
                            <div style="border: 1px solid #ccc; width: 30px; height: 30px; background-color: yellow; ">A</div>
                        </div>
                        <div style="position: absolute; bottom: -50%; height: 100%; display: table-cell; vertical-align: middle;">
                            <div style="border: 1px solid #ccc; width: 30px; height: 30px; background-color: yellow; ">B</div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td style="height: 33.33%;">
                    <div style="position: relative; width: 100%; height: 100%;">
                        <div style="position: absolute; bottom: -50%; height: 100%; display: table-cell; vertical-align: middle;">
                            <div style="border: 1px solid #ccc; width: 30px; height: 30px; background-color: yellow; ">C</div>
                        </div>
                    </div>
                </td>
            </tr>
             <tr>
                <td style="height: 33.33%;">
                  <div style="position: relative; width: 100%; height: 100%;">

                        <div style="position: absolute; bottom: -50%; height: 100%; display: table-cell; vertical-align: middle;">
                            <div style="border: 1px solid #ccc; width: 30px; height: 30px; background-color: yellow; ">D</div>
                        </div>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</body>
</html>

A.
B
C
D

通过添加
利润率上限:50%来修复它用于每个框