我已在 html 中插入了一个图标,但它当前位于内容的左侧,如何将其居中并将其放置在顶部?我在以下位置使用此代码:
谢谢!
不知道如何在css中调用来编辑?
我假设您正在使用图像并且想要将其居中。为此,您需要执行以下操作。
<style>
.center {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
}
</style>
<body>
<img src="icon.png" alt="icon" class="center">
</body>
这将通过左右移动图像来居中。