[英]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.