电子邮件中的滑块代码-希望它适用于Gmail

时间:2018-10-03 06:43:24

标签: html css html5 css3

我之前曾问过有关此代码的问题。一切正常。唯一的问题是,我想使用它,以便它可以在Gmail Web客户端中使用。它似乎可以在Gmail移动版上运行,但不能在台式机上运行,​​而普通的在线HTML可以运行。我知道电子邮件客户端会限制CSS功能,但是获得这种功能的任何帮助都会很棒。

工作片段:

body {
  margin: 0;
  padding: 0;
}
.container {
 display:flex;
 width:600px;
 flex-wrap:wrap;
 justify-content:space-between;
}

.slider-holder {
  order:-1;
  width: 600px;
  height: 280px;
  background-color: yellow;
  text-align: center;
  overflow: hidden;
}

.image-holder {
  width: 3000px;
  background-color: red;
  height: 280px;
  clear: both;
  position: relative;
  transition: left 7000s; /*Use a big value to block the image change*/
  left: 0;
}

.slider-image {
  float: left;
  margin: 0px;
  padding: 0px;
  position: relative;
}

a[href="#slider-image-0"]:hover~.slider-holder .image-holder {
  left: 0.5px; /*Yes it's not 0px here, we need something different from the initial state to be able to trigger the transition (Yes I know it's not intuitive ..)*/
  transition: left 1s;
}

a[href="#slider-image-1"]:hover~.slider-holder .image-holder {
  left: -600px;
  transition: left 1s;
}

a[href="#slider-image-2"]:hover~.slider-holder .image-holder {
  left: -1200px;
  transition: left 1s;
}

a[href="#slider-image-3"]:hover~.slider-holder .image-holder {
  left: -1800px;
  transition: left 1s;
}

a[href="#slider-image-4"]:hover~.slider-holder .image-holder {
  left: -2400px;
  transition: left 1s;
}

.button-holder>a>img {
  padding-left: 35px;
  padding-right: 35px;
}
<div class="container">
<a href="#slider-image-0"><img src="https://via.placeholder.com/70x70" alt="" width="70" style="border-width:0 !important;outline-style:none !important;"></a>
<a href="#slider-image-1"><img src="https://via.placeholder.com/70x70" alt="" width="70" style="border-width:0 !important;outline-style:none !important;"></a>
<a href="#slider-image-2"><img src="https://via.placeholder.com/70x70" alt="" width="70" style="border-width:0 !important;outline-style:none !important;"></a>
<a href="#slider-image-3"><img src="https://via.placeholder.com/70x70" alt="" width="70" style="border-width:0 !important;outline-style:none !important;"></a>
<a href="#slider-image-4"><img src="https://via.placeholder.com/70x70" alt="" width="70" style="border-width:0 !important;outline-style:none !important;"></a>
<div class="slider-holder">
  <div class="image-holder">
    <img src="https://via.placeholder.com/600x280/ff0000" class="slider-image" />
    <img src="https://via.placeholder.com/600x280/00ff00" class="slider-image" />
    <img src="https://via.placeholder.com/600x280/f0f0f0" class="slider-image" />
    <img src="https://via.placeholder.com/600x280/0000ff" class="slider-image" />
    <img src="https://via.placeholder.com/600x280" class="slider-image" />
  </div>
</div>
</div>

2 个答案:

答案 0 :(得分:0)

您应该使用表格布局,内联CSS并避免使用图像代替内容。这是很好的指南:https://litmus.com/blog/a-guide-to-css-inlining-in-email

答案 1 :(得分:0)

这是电子邮件客户端link支持的CSS列表。 尝试在HTML的开头部分添加CSS类。