【发布时间】:2015-08-08 00:44:09
【问题描述】:
我一直在努力开发电子邮件模板,因为我一直在尝试使其具有移动响应能力。对于顶部的假日列表,我尝试在桌面浏览器中每行列出 3 个列表;对于移动浏览器,我希望每行只列出一个列表,以使其看起来适合移动设备。
这里的问题是 <tr> 不支持我将 td 元素设置为 100% 宽度,因为其他元素包含在 <tr> 容器内,并且我被告知电子邮件客户建议使用表格设计,所以我还没有将 div 用作不支持的浮点数等。抱歉代码混乱,显然内联样式最适合电子邮件。这是代码:http://codepen.io/anon/pen/vOPNXw
<div style="padding:20px; background-color:rgb(37,119,161);">
<tbody>
<tr>
<td style="width:30%; margin-bottom:5px;">
<img src="http://au.clubmatestravel.com/panel/upload/thumbnails/0CM15037-4.jpg_listing" style="width:100%; height:250px;">
<h3 style="text-decoration:underline; padding: 5px; color:orange; font-weight:bold;">Eureka Spa</h3>
<h3 style="padding: 5px; color:orange;">Departing on: 10-08-2015</h3>
<div style="overflow:hidden; height:200px; padding:20px; background-color:white;"><p>Make our way into Daylesford for some great bargain hunting. No visit to Daylesford is complete without a visit to the Chocolate Mill for some home-made chocolates and a nice hot chocolate!</p></div>
<a href="http://au.clubmatestravel.com/holiday/Eureka-Spa"><button style=" display: inline-block;margin-bottom: 0;font-weight: 400;text-align: center;vertical-align: middle;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 14px;line-height: 1.42857143;border-radius: 4px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;width:100%; float:left;height:50px; color: #fff; background-color: #47a447; border-color: #398439; ">View</button></a>
<a href="http://au.clubmatestravel.com/contact?mode=enquiry&tour=122"><button style=" display: inline-block;margin-bottom: 0;font-weight: 400;text-align: center;vertical-align: middle;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 14px;line-height: 1.42857143;border-radius: 4px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;width:100%; float:left;height:50px; color: #fff; background-color: #47a447; border-color: #398439; ">Enquire</button></a>
</td>
<td style="width:30%; margin-bottom:5px;">
<img src="http://au.clubmatestravel.com/panel/upload/thumbnails/0CM15043-4.JPG_listing" style="width:100%; height:250px;">
<h3 style="text-decoration:underline; padding: 5px; color:orange; font-weight:bold;">Mildura Music Festival </h3>
<h3 style="padding: 5px; color:orange;">Departing on: 24-09-2015</h3>
<div style="overflow:hidden; height:200px; padding:20px; background-color:white;"><p>Grab your hat and board the country music express. The country music kicks in as soon as you step onto the coach, and you will be <br>pumping out the vibes as you cruise the open highway up to the riverside town of Mildura. You will be bootscootin, shakin' your bootie, line dancing and any other way you like to do your thing!</p></div>
<a href="http://au.clubmatestravel.com/holiday/Mildura-Music-Festival "><button style=" display: inline-block;margin-bottom: 0;font-weight: 400;text-align: center;vertical-align: middle;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 14px;line-height: 1.42857143;border-radius: 4px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;width:100%; float:left;height:50px; color: #fff; background-color: #47a447; border-color: #398439; ">View</button></a>
<a href="http://au.clubmatestravel.com/contact?mode=enquiry&tour=123"><button style=" display: inline-block;margin-bottom: 0;font-weight: 400;text-align: center;vertical-align: middle;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 14px;line-height: 1.42857143;border-radius: 4px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;width:100%; float:left;height:50px; color: #fff; background-color: #47a447; border-color: #398439; ">Enquire</button></a>
</td>
<td style="width:30%; margin-bottom:5px;">
<img src="http://au.clubmatestravel.com/panel/upload/thumbnails/0CM15049-1.JPG_listing" style="width:100%; height:250px;">
<h3 style="text-decoration:underline; padding: 5px; color:orange; font-weight:bold;">Wangaratta Jazz & Blues</h3>
<h3 style="padding: 5px; color:orange;">Departing on: 29-10-2015</h3>
<div style="overflow:hidden; height:200px; padding:20px; background-color:white;"><p>Travel to the Jazz Festival and embrace all the goodness that Wangaratta has to offer!</p></div>
<a href="http://au.clubmatestravel.com/holiday/Wangaratta-Jazz-and-Blues"><button style=" display: inline-block;margin-bottom: 0;font-weight: 400;text-align: center;vertical-align: middle;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 14px;line-height: 1.42857143;border-radius: 4px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;width:100%; float:left;height:50px; color: #fff; background-color: #47a447; border-color: #398439; ">View</button></a>
<a href="http://au.clubmatestravel.com/contact?mode=enquiry&tour=124"><button style=" display: inline-block;margin-bottom: 0;font-weight: 400;text-align: center;vertical-align: middle;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 14px;line-height: 1.42857143;border-radius: 4px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;width:100%; float:left;height:50px; color: #fff; background-color: #47a447; border-color: #398439; ">Enquire</button></a>
</td>
</tr><tr>
<td style="width:30%; margin-bottom:5px;">
<img src="http://au.clubmatestravel.com/panel/upload/thumbnails/0CM15048-2.jpg_listing" style="width:100%; height:250px;">
<h3 style="text-decoration:underline; padding: 5px; color:orange; font-weight:bold;">WA Dolphin Delights</h3>
<h3 style="padding: 5px; color:orange;">Departing on: 24-10-2015</h3>
<div style="overflow:hidden; height:200px; padding:20px; background-color:white;"><p>Get to visit the amazing beaches and far less populated West. Prepare for a great time seeing the Dolphins. Be carried away by the <br>beautiful sights of Perth from Kings Park!</p></div>
<a href="http://au.clubmatestravel.com/holiday/WA-Dolphin-Delights"><button style=" display: inline-block;margin-bottom: 0;font-weight: 400;text-align: center;vertical-align: middle;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 14px;line-height: 1.42857143;border-radius: 4px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;width:100%; float:left;height:50px; color: #fff; background-color: #47a447; border-color: #398439; ">View</button></a>
<a href="http://au.clubmatestravel.com/contact?mode=enquiry&tour=130"><button style=" display: inline-block;margin-bottom: 0;font-weight: 400;text-align: center;vertical-align: middle;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 14px;line-height: 1.42857143;border-radius: 4px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;width:100%; float:left;height:50px; color: #fff; background-color: #47a447; border-color: #398439; ">Enquire</button></a>
</td>
<td style="width:30%; margin-bottom:5px;">
<img src="http://au.clubmatestravel.com/panel/upload/thumbnails/0CM15040-1.JPG_listing" style="width:100%; height:250px;">
<h3 style="text-decoration:underline; padding: 5px; color:orange; font-weight:bold;">Camels, Pearls & Whales</h3>
<h3 style="padding: 5px; color:orange;">Departing on: 03-09-2015</h3>
<div style="overflow:hidden; height:200px; padding:20px; background-color:white;"><p>Discover the Dinosaurs footprints at low tide, have an exciting camel ride along Cable Beach, and enjoy how rich the wildlife is at the spectacular Broome! </p></div>
<a href="http://au.clubmatestravel.com/holiday/Camels-Pearls-and-Whales"><button style=" display: inline-block;margin-bottom: 0;font-weight: 400;text-align: center;vertical-align: middle;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 14px;line-height: 1.42857143;border-radius: 4px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;width:100%; float:left;height:50px; color: #fff; background-color: #47a447; border-color: #398439; ">View</button></a>
<a href="http://au.clubmatestravel.com/contact?mode=enquiry&tour=131"><button style=" display: inline-block;margin-bottom: 0;font-weight: 400;text-align: center;vertical-align: middle;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 14px;line-height: 1.42857143;border-radius: 4px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;width:100%; float:left;height:50px; color: #fff; background-color: #47a447; border-color: #398439; ">Enquire</button></a>
</td>
<td style="width:30%; margin-bottom:5px;">
<img src="http://au.clubmatestravel.com/panel/upload/thumbnails/0CM15046-3.jpg_listing" style="width:100%; height:250px;">
<h3 style="text-decoration:underline; padding: 5px; color:orange; font-weight:bold;">Sunset Markets</h3>
<h3 style="padding: 5px; color:orange;">Departing on: 17-10-2015</h3>
<div style="overflow:hidden; height:200px; padding:20px; background-color:white;"><p>Make your way to Berry Springs to the Territory Wildlife Park where you can view the wildlife up close, take a walk around the lagoon, go into the walk-through aquarium to view the amazing aquatic life and come nose to nose with a giant saltwater crocodile! This afternoon we are off to Berry Springs Nature Park for a refreshing swim. Don’t forget to wear your goggles so you can see many small native fish and other aquatic life that live in the clear pools. Wildlife is abundant!</p></div>
<a href="http://au.clubmatestravel.com/holiday/Sunset-Markets"><button style=" display: inline-block;margin-bottom: 0;font-weight: 400;text-align: center;vertical-align: middle;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 14px;line-height: 1.42857143;border-radius: 4px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;width:100%; float:left;height:50px; color: #fff; background-color: #47a447; border-color: #398439; ">View</button></a>
<a href="http://au.clubmatestravel.com/contact?mode=enquiry&tour=135"><button style=" display: inline-block;margin-bottom: 0;font-weight: 400;text-align: center;vertical-align: middle;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 14px;line-height: 1.42857143;border-radius: 4px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;width:100%; float:left;height:50px; color: #fff; background-color: #47a447; border-color: #398439; ">Enquire</button></a>
</td>
</tr><tr>
</tr>
【问题讨论】:
-
你可以使用 display: 块吗?我不知道,是否可以在电子邮件标记上使用它
-
一张表和
display:block用于 tr 和 td 确实是普通网站的解决方案。如果您可以使用@media 查询。然而,对于电子邮件客户端,所有的赌注都没有了。一个快速而肮脏的测试表明,@media 技巧在 SeaMonkey(可能还有 Thunderbird)中有效,但在 gmail 网站上无效。所以我不会辜负你的希望。但是this post 有帮助吗? -
我的代码并没有真正起作用,td 元素出于某种原因移出了 table 元素,即使我在 td 中编写了表格。无论如何,我想我必须在这个上做一个赏金。无论如何,谢谢伙计
-
只需为父 div 元素添加
display: inline-block;。它会正常工作的。
标签: html css responsive-design html-email