html - 居中 png 图像

标签 html css

<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Name of your Animal</title>
    <link rel = "stylesheet"
   type = "text/css"
   href = "style1.css" />

   </head>
   <body>

    <img src="jags2.png" alt="jaguar">
    <img align="right">


    <p> Add some info on your animal </p>
  </body>
</html>

我正在尝试制作一个关于美洲虎的网站,我插入了一张美洲豹的照片,但它一直显示在左上角。我正在尝试将其居中对齐,但行不通,请帮忙。

最佳答案

尝试以下 引用:https://www.w3schools.com/css/css_align.asp

.center img {
    margin: 0;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translate(-50%, -100%);
}
<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Name of your Animal</title>
    <link rel = "stylesheet"
   type = "text/css"
   href = "style1.css" />

   </head>
   <body>
    <div class="center">
        <img  src="https://tpc.googlesyndication.com/simgad/11423376298074074248" alt="jaguar">
    </div>

  </body>
</html>

关于html - 居中 png 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53402178/

相关文章:

html - 如何使用 html/javascript/jquery 将 golang http json 主体输出到网站页面

html - 为什么 table-caption 会增加表格的高度?

html - 使用 css 从递归结构中选择 ul li 列表中的最后一个元素 gg

HTML/CSS 标签 : Labels taking on the properties of other labels

php - WP js_composer.min.css 不申请单发

html - 无法在表格单元格中垂直居中 float 元素

html - 使用响应式图像构建信息卡

css - 在基于 CSS 的绝对定位 UL 对齐(下拉效果)方面需要帮助

html - 水平和垂直居中表格单元格的内容?

javascript - 用 jquery 加载填充 div 中的值