如何使用CSS在图片旁边设置表格位置?

时间:2019-02-10 05:46:25

标签: javascript html css

我要在图片的右侧设置桌子的位置。

这是我的代码:

<html>
<head>
	<style type="text/css">
		.podium { display: block; margin-left: 300; margin-top: 500; position: static; }
		table { position: relative; left: 100px; }
	</style>
</head>
<body>
	<img src="podium.jpg" class="podium">
	<table border="5px">
		<tr>
			<td>aaa</td>
		</tr>
	</table>
</body>
</html>

我已经尝试过了,但是没有用。

我该怎么做?

1 个答案:

答案 0 :(得分:1)

将图像和表格包装在div中,然后可以使用Flex order的flex和flex-order属性。

#wrapper{ display: flex; }
#image{ order:2; width: 100px; height:100px; margin-left:15px}
#table{ order:1; }
<div id='wrapper'>
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSNyNcwf4fDjX_2L4mUcJNmg92fOmWlDTYxcefggBG0VAr6MX32" class="podium" id='image'>
<table border="5px" id='table'>
  <tr>
    <td>aaa</td>
  </tr>
</table>
</div>