<!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/