我試圖中心包含一個div內的桌子上的內容...但我似乎無法找出如何做到這一點上居中的內容...如何一個div
基本上我還想放一些文本旁邊的一個表,中心表和文本的網頁...
內容我試圖中心:
<div style="background: purple; padding: 5px;">
<div>
<table style="float: left;">
<tr>
<th>This</th>
<th>is</th>
<th>a</th>
<th>test</th>
</tr>
</table>
</div>
<span style="background: yellow; margin-left: 15px; float: left;">This is a test</span>
</div>
我曾嘗試:
<div style="background: red; width: 100%; text-align: center">
<div style="background: purple; padding: 5px;">
<div>
<table style="float: left;">
<tr>
<th>This</th>
<th>is</th>
<th>a</th>
<th>test</th>
</tr>
</table>
</div>
<span style="background: yellow; margin-left: 15px; float: left;">This is a test</span>
</div>
</div>
如果有人能夠告訴我我在做什麼錯誤在這裏會大大讚賞。
給父'div'(即紫色背景)一個寬度,然後使用'margin:0 auto'。 – BenM
我的工作代理不允許jsfiddle ...對不起:( – craig1231