我有一个java应用程序,每天发送邮箱摘要使用thymeleaf模板构建.邮箱在大多数环境中正确呈现.唯一有问题的地方似乎是iOS中的本地邮件客户端.出于某种原因,内容在那里被调整大小;缩小,使得文本小得无法阅读.

我试着加上

Style="空格:预换行"

到保存消息内容的标签,一开始似乎还能用.然而,今天,问题又回来了,我不知道是什么原因造成的.下面是邮箱在iOS中的样子的截图.

有什么 idea ,我可以做什么,以迫使内容,以配合屏幕宽度,而不闪烁?

以下是我使用的模板,以供参考:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Message Center Digest</title>
    <style>a {color:#007aae !important;} </style>
</head>
<body>
<table id="main" width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td bgcolor="#003575">
            <table id="header" width="90%" border="0" cellpadding="0" cellspacing="0" align="center">
                <tr>
                    <td width="35%">
                        <a href="https://www.foo.edu"><img alt="My Logo" width="100px" border="0" src="https://www.foo.edu/sites/logo_white.png" /></a></td>
                    <td width="65%">
                        <h1 style="color: #ffffff; font-family: helvetica, arial, sans-serif; font-weight: normal; font-size: 30px; margin: 0;">Message Center Digest</h1>
                        <h2 style="margin: 0; font-weight: normal; font-family: Helvetica, Arial, sans-serif; color: #ffffff; font-size: 24px;">For <span th:text="${data.day}">Some day</span>, <a href="#" style="color: #ffffff !important; text-decoration: none;"><span th:text="${data.date}">01/01/1970</span></a></h2>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td bgcolor="#EAEEF1">
            <table width="90%" id="content" bgcolor="#ffffff" align="center" border="0" cellpadding="15" cellspacing="0" style="font-family: Arial, Helvetica, sans-serif;">
                <tr>
                    <td>
                        <a name="pagetop"></a>
                        <h3 style="font-size: 18px; margin: 0 0 5px 0;">Table of Contents</h3>
                        <h4 style="margin: 0 0 10px 0; font-size: 13px;"><a href="https://www1.foo.edu/script/LogList.asp">Campus Crime and Fire Safety Logs</a></h4>
                        <div th:each="entry, stats : ${messageMap}" th:with="channelMessage=${entry.value}">
                            <h4 th:attr="id=${'header_' + channelMessage.channelId}" th:text="${entry.key}" style="margin: 0; font-size: 13px;">Category</h4>
                            <ul th:attr="id=${'titles_' + channelMessage.channelId}" id="titles"  style="list-style: none; margin: 0 0 10px 0; padding-left: 15px; font-size: 13px;">
                            <li th:attr="id=${'t_' + message.id + '_' + channelMessage.channelId}" th:each="message : ${channelMessage.messages}"><a th:text="${message.title}" th:href="${'#message_' + message.id + '_' + channelMessage.channelId}">Title 1 </a></li>
                            </ul>
                        </div>
                        <table th:each="entry, stats : ${messageMap}" th:with="channelMessage=${entry.value}" class="category" width="100%" border="0" align="center" cellpadding="10" cellspacing="0">
                            <tr>
                                <td>
                                    <h2 th:attr="id='category_'+${channelMessage.channelId}" th:text="'Category: ' + ${entry.key}" style="color: #00397C; margin: 0;">Category: Unknown</h2>
                                    <table th:each="message : ${channelMessage.messages}" class="message" width="100%" align="center" cellpadding="0" cellspacing="0" border="0" style="border-bottom: solid #ccc 1px;">
                                        <tr>
                                            <td style="font-size: 13px; color: #333333; padding-left: 15px; padding-bottom: 15px; padding-top: 15px;">
                                                <a th:attr="name=${'message_' + message.id + '_' + channelMessage.channelId}" id="message1"></a>
                                                <span th:attr="id=${'title_' + message.id + '_' + channelMessage.channelId}" ><strong th:text="${message.title}">A title</strong></span><br/>
                                                    <span th:attr="id=${'from_' + message.id + '_' + channelMessage.channelId}"><strong th:inline="text">[['From: ' + ${message.creatorName} + ' ']]<a th:href="@{mailto:{to}(to=${message.creatorEmail},subject='Re: '+ ${message.title}) }" th:text="'<'+${message.creatorEmail} + '>'">foo@gmail.com</a></strong></span><br/><br />
                                                    <div th:switch="${message.isHtml}">
                                                        <p Style="空格:预换行" th:attr="id=${'body_' + message.id + '_' + channelMessage.channelId}" th:case="true" th:utext="${message.body}">HTML text</p>
                                                        <p Style="空格:预换行" th:attr="id=${'body_' + message.id + '_' + channelMessage.channelId}" th:case="*" th:text="${message.body}">Standard text</p>
                                                    </div>
                                                <p><a href="#pagetop">Top</a></p>
                                            </td>
                                        </tr>
                                    </table>

                                </td>
                            </tr>
                        </table>
                        <br />
                        <br />
                        <br />
                        <p align="center" style="font-size: 13px;"><em>Update how you receive messages by visiting the Message Center.
                            For help using the Message Center, email: <a href="mailto:foo@bar.edu">foo@bar.edu</a> or call 555-123-4567.</em></p>

                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
</body>
</html>

推荐答案

我很久以前也做过类似的事情.

事情是这样的,我不确定为什么,但是你必须定义所有的东西,并且由于某些原因,页面的主体不会占据整个屏幕的大小.

在标记之间添加此阶段,使其如下所示:

<head> 
 ...somethings


<style>    body {     margin: auto;     width: 100%;   }  </style>

...somethings
</head>

Css可以改变在页面上查看html的方式,所以我只是添加了带有一些css的style标签.

看看这this example个.

你可以像编辑普通网页一样编辑超文本标记语言,所以下次如果出现错误,只需在你的电脑上把超文本标记语言写成textfile.html,然后在浏览器上打开它,你就可以控制它了 就像在this video里.

Html相关问答推荐

HTML CSS如何使用图像作为中心点将元素置于中心

如何在一个div中心字体图标?

如何找到FontAwese图标的Unicode值?

由于列中的图像,它们不会随FlexBox中的窗口大小进行调整

禁用与行分开的边框折叠span

如何修复与导航栏重叠的css网格?

有没有一种方法可以动态地从网格或Flexbox中取出HTML元素?

轨道上的居中范围滑块拇指(Webkit)

SVG动画只有在打开S开发工具的浏览器时才开始播放

柔性盒内的物品;t覆盖整个宽度,即使设置为100%

如何将tmap按钮和图例更改为位于页脚后面?

Flex:第一个 div 有列,下一个 div 有行

Github上部署需要花费几小时时间:等待github pages部署批准

子元素放在文本样式之后,样式会 destruct

如何正确地嵌套Flexbox

Sass 混合动画未正确应用

如何在Bootstrap卡片底部添加波浪形状

如何使 Shiny 中的 selectInput Select 扩展到井面板之外或以其他方式使它们更容易被用户看到?

发光效果html动画

自定义进度条 Html 和 CSS 布局