英文:
Hot to make element in the center if I don't use justify-content?
问题
我的HTML文件是用于“HTML电子邮件”,因此我无法使用“justify-content”。
以下是居中的原始代码:
<div style="display: flex; justify-content: center;">
<p>Hello &nbsp</p>
<p>World</p>
</div>
对于“HTML电子邮件”,我必须放弃使用“justify-content”,改用“text-align: center”:
<div style="display: flex; text-align: center;">
<p>Hello &nbsp</p>
<p>World</p>
</div>
但是在结果中,元素位于左侧而不是居中,如果我必须使用“display: flex”,应该如何实现它以适用于“HTML电子邮件”?
英文:
My HTML file is for html email
, so I can't use justify-content
.
Here is the original code for center:
<div style="display: flex; justify-content: center;">
<p>Hello &nbsp</p>
<p>World</p>
</div>
For html email
I have to give up use justify-content
, change to use text-align: center
<div style="display: flex; text-align: center;">
<p>Hello &nbsp</p>
<p>World</p>
</div>
but in the result element is on the left side not in the center, if I have to use display: flex
How to achieve it for html email
?
答案1
得分: 1
为什么要使用 flex 呢?尝试这样做:
<div style="text-align:center;">
<p style="display:inline-block;">Hello &nbsp</p>
<p style="display:inline-block;">World</p>
</div>
英文:
Why use flex then? Try this:
<div style="text-align:center;">
<p style="display:inline-block;">Hello &nbsp</p>
<p style="display:inline-block;">World</p>
</div>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论