Html Microsoft Outlook 中的中心 div

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10137536/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 23:45:50  来源:igfitidea点击:

Center div in Microsoft Outlook

htmlcssoutlook

提问by Maarten Kuilman

I used <div style="width: 742px; margin: 0px auto; ">to center the container div.

我曾经<div style="width: 742px; margin: 0px auto; ">将容器居中div

In the browser it works, but when I open it in Microsoft Outlook it's not in the center.

在浏览器中它可以工作,但是当我在 Microsoft Outlook 中打开它时它不在中心。

I also used !importanton the marginbecause I thought it took precedence over the CSS.

我也使用!important过,margin因为我认为它优先于 CSS。

How do I center a divin the browser and email?

如何div在浏览器和电子邮件中居中 a ?

回答by Rohit Azad

<div align="center">

your code 

</div>

Only for Outlook

仅适用于 Outlook

回答by Tacquet Benjamin

For emailing in general it is better to do use html attributes and deprecated tags instead of their CSS equivalents because some messaging systems ignore inline styles.

对于一般的电子邮件,最好使用 html 属性和不推荐使用的标签而不是它们的 CSS 等效项,因为某些消息传递系统会忽略内联样式。

For example, instead of:

例如,而不是:

<div style="width: 742px; margin: 0px auto; ">...

You can use:

您可以使用:

<body align="center"><table align="center" width="742">...

Or

或者

<div align="center">...

Example 2, instead of:

示例 2,而不是:

<p style="font-family: Arial, Helvetica, Tahoma, sans-serif;">My text</p>

You can do:

你可以做:

<font face="Arial" size="4">My text</font>

回答by Nek

A good reflex is to go on the official Microsoft Documentation Network: http://msdn.microsoft.com/en-us/library/aa338201.aspx

一个很好的反应是去微软官方文档网络:http: //msdn.microsoft.com/en-us/library/aa338201.aspx

Here you can see that the best method is to use.. another thing than a div element.

在这里你可以看到最好的方法是使用.. div 元素之外的另一件事。

Use a table, it allow the maximum of css control.

使用表格,它允许最大的 css 控制。