javascript - 如何用CSS设置图片旁边的表格位置?

标签 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>

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

我怎样才能做到?

最佳答案

将图像和表格包装在一个 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>

关于javascript - 如何用CSS设置图片旁边的表格位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54613726/

相关文章:

javascript - if 条件中的对象解构会产生全局变量吗?

javascript - 从特定的 li 中获取复选框值

HTML 背景大小

javascript - 为什么这些内联 block div 不适合它们的容器?

html - 溢出:隐藏不能始终如一地工作

javascript - 如何使用 react-router 创建反向路由

javascript - 在node.js中设置Apache环境变量

html - 无法隐藏与 z-index 的链接

javascript - 在页面加载时淡入 div

html - 有什么方法可以将 block 样式/CSS 转换为内联 CSS?