如何将图标置于页面顶部中心?

问题描述 投票:0回答:1

我已在 html 中插入了一个图标,但它当前位于内容的左侧,如何将其居中并将其放置在顶部?我在以下位置使用此代码:

谢谢!

不知道如何在css中调用来编辑?

html css hyperlink icons
1个回答
0
投票

我假设您正在使用图像并且想要将其居中。为此,您需要执行以下操作。

     <style>
    .center {
      display: block;
      margin-left: auto;
      margin-right: auto;
      width: 50%;
    }
    </style>
    <body>
    <img src="icon.png" alt="icon" class="center">
    </body>

这将通过左右移动图像来居中。

© www.soinside.com 2019 - 2024. All rights reserved.