[英]HTML Centered Title with Image Left Aligned
如何使图像与页面左角对齐且标题居中?
我尝试了什么:
<div style="display: flex; height: 100px;">
<img style="max-width: 100%; max-height: 100%;" src="static/totally_original_logo.jpg" alt="totally original logo">
<div style="text-align: center; margin: 0 auto;">
<a href="foo.com">Return to home</a>
<h1>My Title</h1>
</div>
</div>
<div style="display: flex; height: 100px; justify-content: center;">
<img style="max-width: 100%; max-height: 100%;" src="static/totally_original_logo.jpg" alt="totally original logo">
<div style="text-align: center;">
<a href="foo.com">Return to home</a>
<h1>My Title</h1>
</div>
</div>
保持justify-content: center
并给 img 一个justify-self: start
属性。 您可能还需要为 div 提供 100% 的宽度。
img {
justify-self: start;
}
div {
width: 100%;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.