我尝试使用下面的代码,但标题出现在下一行。 代码如下:
<div style="display:inline;">
<img src="abc.png" style="margin:10px 10px 10px 10px;width:97px;height:50px;" />
<h5 style="display:inline-block">Hello</h5></div>
最佳答案
像下面这样改变你的风格。将 float:left; 添加到 img 和 h5 标签 以获得结果。
更新的输出
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div style="display: inline-block;width: 100%;">
<img src="https://smallbusinesssaturdayuk.com/Images/Small-Business-Saturday-UK-Google-Plus.gif" style="float:left;" />
<h5 style="text-align:center;">Hello</h5>
</div>
</body>
</html>
关于html - 如何对齐左边的图像和中间的标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39161005/