<style> .parent{ border: 1px solid red; height: 500px } .child{ border: 1px solid black } </style> <body> <!-- --> <table class="parent"> <tr> <td class="child"> 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 測試 </td> </tr> </table> </body>
<style> .parent{ position: relative; background-color: yellow; width: 500px; height: 200px } .child{ width: 100px; height: 100px; background-color: #fff; position:absolute; top:50%; left: 50%; margin-left: -50px; margin-top: -50px } </style>
<style> .parent{ width: 500px; height: 300px; border: solid 1px red; position: relative; } .child{ width: 200px; height: 100px; border: 1px solid black; position:absolute; top:50%; left:50%; transform: translate(-50%,-50%) } </style>
<style> .p{ width: 300px; height: 200px; border: 1px solid red; position: relative; } .c{ width: 80px; height: 40px; background-color: #dedede; position:absolute; margin: auto; top:0; bottom:0; left: 0; right: 0 } </style>
<style> .p{ border: 1px solid red; width: 400px; height: 500px; display: flex; justify-content: center; align-items: center } .c{ width: 100px; height: 100px; background-color: red; } </style>
HTML5 如今已經不是 SGML 的子集,主要是關於圖像,位置,存儲,地理定位等功能的增長。html
- <!--[if lt IE 9]> <script> src="http://html5shim.googlecode.com/svn/trunk/html5.js"</script> <![endif]-->