Slider code in email - Want it to work for Gmail - html

I have asked questions regarding this code before. It is working fine. The only issue is that I would like to use it so the it works in the Gmail web client. It seems to work on Gmail mobile but not desktop and normal online HTML works. I know email clients limit CSS functionality but any help in getting functionality like this working would be great.
WORKING SNIPPET:
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">
<img src="https://via.placeholder.com/70x70" alt="" width="70" style="border-width:0 !important;outline-style:none !important;">
<img src="https://via.placeholder.com/70x70" alt="" width="70" style="border-width:0 !important;outline-style:none !important;">
<img src="https://via.placeholder.com/70x70" alt="" width="70" style="border-width:0 !important;outline-style:none !important;">
<img src="https://via.placeholder.com/70x70" alt="" width="70" style="border-width:0 !important;outline-style:none !important;">
<img src="https://via.placeholder.com/70x70" alt="" width="70" style="border-width:0 !important;outline-style:none !important;">
<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>

You should use table layout, inline css and avoid using images as replace of content. Here is great guide: https://litmus.com/blog/a-guide-to-css-inlining-in-email

here is the list of CSS supported by email clients link.
Try to add you CSS classes in head section of HTML.

Related

Hover Effect Transform property

I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
.imageWrapper {
position: relative;
width: 200px;
height: 200px;
display: inline-block;
padding: 0px;
margin: 0px;
}
.imageWrapper img {
display: block;
width: 200px;
height: 200px;
padding: 0px;
margin: 0px;
}
.imageWrapper .cornerLink {
height:100px;
width:200px;
opacity: 0.7;
position: absolute;
bottom: 0px;
left: 0px;
margin: 0;
padding: 0;
color: #ffffff;
background-color: cadetblue;
text-decoration: none;
text-align: center;
transform: translateX(0) translateY(100px) translateZ(0);
transition-duration:0.3s;
transition-property: transform;
}
.imageWrapper:hover .cornerLink {
transform: translateX(0) translateY(0) translateZ(0);
}
a{
color: #ffffff;
text-decoration: none;
text-align: center;
}
<body>
<main>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
</main>
</body>
Add overflow:hidden; to your .imageWrapper class. Here's working code:
.imageWrapper {
position: relative;
width: 200px;
height: 200px;
display: inline-block;
padding: 0px;
margin: 0px;
overflow:hidden;
}
.imageWrapper img {
display: block;
width: 200px;
height: 200px;
padding: 0px;
margin: 0px;
}
.imageWrapper .cornerLink {
height:100px;
width:200px;
opacity: 0.7;
position: absolute;
bottom: 0px;
left: 0px;
margin: 0;
padding: 0;
color: #ffffff;
background-color: cadetblue;
text-decoration: none;
text-align: center;
transform: translateX(0) translateY(100px) translateZ(0);
transition-duration:0.3s;
transition-property: transform;
}
.imageWrapper:hover .cornerLink {
transform: translateX(0) translateY(0) translateZ(0);
}
a{
color: #ffffff;
text-decoration: none;
text-align: center;
}
<body>
<main>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
</main>
</body>
Change this line transform: translateX(0) translateY(100px) translateZ(0); to transform: translateX(0) translateY(115px) translateZ(0);:
Add overflow:hidden to .imageWrapper to remove the space under images
.imageWrapper {
position: relative;
width: 200px;
height: 200px;
display: inline-block;
padding: 0px;
margin: 0px;
overflow: hidden; /* Hides links when off image */
}
.imageWrapper img {
display: block;
width: 200px;
height: 200px;
padding: 0px;
margin: 0px;
}
.imageWrapper .cornerLink {
height: 100px;
width: 200px;
opacity: 0.7;
position: absolute;
bottom: 0px;
left: 0px;
margin: 0;
padding: 0;
color: #ffffff;
background-color: cadetblue;
text-decoration: none;
text-align: center;
transform: translateX(0) translateY(100px) translateZ(0);
transition-duration: 0.3s;
transition-property: transform;
}
.imageWrapper:hover .cornerLink {
transform: translateX(0) translateY(0) translateZ(0);
}
a {
color: #ffffff;
text-decoration: none;
text-align: center;
}
<body>
<main>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
</main>
</body>

Is there a way to modify this without JS or Jquery?

I found this image carousel here I'm wondering if there is a way to make it not auto scroll but instead have navigation buttons, as well as make it responsive. Is there a way to do this but still keep it Css only?
<h1>css3 carousel</h1>
<div class="carousel">
<div class="holder">
<img src="http://fakeimg.pl/200x100" alt="" />
<img src="http://fakeimg.pl/300x200" alt="" />
<img src="http://fakeimg.pl/400x300" alt="" />
<img src="http://fakeimg.pl/200x100" alt="" />
<img src="http://fakeimg.pl/500x400" alt="" />
<img src="http://fakeimg.pl/210x105" alt="" />
<img src="http://fakeimg.pl/200x100" alt="" />
<img src="http://fakeimg.pl/250x150" alt="" />
<img src="http://fakeimg.pl/200x100" alt="" />
<img src="http://fakeimg.pl/200x100" alt="" />
<img src="http://fakeimg.pl/200x100" alt="" />
<img src="http://fakeimg.pl/200x100" alt="" />
</div>
</div>
#import url(http://fonts.googleapis.com/css?family=PT+Sans);
body {
font-family: 'PT Sans', Arial, Verdana;
background-color: #eee;
}
h1 {
text-align: center;
font-size: 48px;
text-transform: uppercase;
letter-spacing: 3px;
color: #222;
}
img {
display: inline-block;
width: 200px;
height: 100px;
}
.carousel {
width: 830px;
height: 120px;
overflow: hidden;
padding: 8px;
box-sizing: border-box;
border: 2px solid #999;
box-shadow: 0 0 4px #000;
margin: 0 auto;
border-radius: 5px;
}
.holder {
animation: carousel 25s linear infinite;
white-space: nowrap;
will-change: transform;
&:hover {
animation-play-state: paused;
}
}
#keyframes carousel {
0% {
transform: translateX(0);
}
50% {
transform: translateX(-100%);
}
100% {
transform: translateX(0);
}
}
Changing your CSS slightly will add a basic hover functionality to start the slider form a stopped position.
.holder {
animation: carousel 25s linear;
white-space: nowrap;
will-change: transform;
animation-play-state: paused;
&:hover {
animation-play-state: running;
}
}
Making it responsive would be easy with 'media queries'.
But considering you want to make it responsive then you will need 'click events' to make it work on mobile (as mobile has no hover functionality). CSS can't do click events so you will need javascript or jQuery. But this should be fairly straight forward, you'll only be changing minor CSS with a simple click event. However considering the endless amount of free and basic carousel plugins out there, I would opt for one of them. What you have here seems to be a demonstration on CSS animations, and without some kind of javascript, you will always be limited when it comes to CSS animation control.

CSS Centering An Image

Yes, I know this has been asked countless times and I've read just about every posting I can find but still no solution to my specific issue. On a classified ad site with thumbnail hovers to view the larger image, I need the hovered images to be centered horizontally on the page and vertically within the browser window. So far, when I get it centered horizontally in the browser, the vertical is centered on the page which is often far longer than the window so the images appear either off the screen or at the top edge. If I center it vertically, then it follows the hover horizontally and goes off the screen that way too.
The images, though similar in the HTML example below, are being loaded dynamically and can have varying heights which is part of the problem as I can't simply specify a height. It boils down to the last two CSS blocks with absolute, which causes the vertical centering to work but not the horizontal. Using fixed aligns horizontally but then it's often off the screen vertically. Any ideas?
<p><div class="image-container">
<a class="mouseover-thumbnail-holder" ontouchstart=""><img src="/images/classifieds/68/thumbnails/hpim2079.jpg" alt="hpim2079.jpg" width="69" height="52" /><img class="large-image-style" src="/images/classifieds/68/hpim2079.jpg" alt="hpim2079.jpg" width="323" height="244" /></a>
<a class="mouseover-thumbnail-holder" ontouchstart=""><img src="/images/classifieds/68/thumbnails/hpim2080.jpg" alt="hpim2080.jpg" width="69" height="52" /><img class="large-image-style" src="/images/classifieds/68/hpim2080.jpg" alt="hpim2080.jpg" width="323" height="244" /></a>
<a class="mouseover-thumbnail-holder" ontouchstart=""><img src="/images/classifieds/68/thumbnails/hpim2081.jpg" alt="hpim2081.jpg" width="69" height="52" /><img class="large-image-style" src="/images/classifieds/68/hpim2081.jpg" alt="hpim2081.jpg" width="323" height="244" /></a>
<a class="mouseover-thumbnail-holder" ontouchstart=""><img src="/images/classifieds/68/thumbnails/hpim2082.jpg" alt="hpim2082.jpg" width="69" height="52" /><img class="large-image-style" src="/images/classifieds/68/hpim2082.jpg" alt="hpim2082.jpg" width="323" height="244" /></a>
<a class="mouseover-thumbnail-holder" ontouchstart=""><img src="/images/classifieds/68/thumbnails/hpim2083.jpg" alt="hpim2083.jpg" width="69" height="52" /><img class="large-image-style" src="/images/classifieds/68/hpim2083.jpg" alt="hpim2083.jpg" width="323" height="244" /></a>
<a class="mouseover-thumbnail-holder" ontouchstart=""><img src="/images/classifieds/68/thumbnails/hpim2084.jpg" alt="hpim2084.jpg" width="69" height="52" /><img class="large-image-style" src="/images/classifieds/68/hpim2084.jpg" alt="hpim2084.jpg" width="323" height="244" /></a>
<a class="mouseover-thumbnail-holder" ontouchstart=""><img src="/images/classifieds/68/thumbnails/hpim2115.jpg" alt="hpim2115.jpg" width="70" height="53" /><img class="large-image-style" src="/images/classifieds/68/hpim2115.jpg" alt="hpim2115.jpg" width="323" height="244" /></a>
<a class="mouseover-thumbnail-holder" ontouchstart=""><img src="/images/classifieds/68/thumbnails/hpim2116.jpg" alt="hpim2116.jpg" width="70" height="53" /><img class="large-image-style" src="/images/classifieds/68/hpim2116.jpg" alt="hpim2116.jpg" width="323" height="244" /></a>
<a class="mouseover-thumbnail-holder" ontouchstart=""><img src="/images/classifieds/68/thumbnails/hpim2117.jpg" alt="hpim2117.jpg" width="70" height="53" /><img class="large-image-style" src="/images/classifieds/68/hpim2117.jpg" alt="hpim2117.jpg" width="323" height="244" /></a>
</div>
The CSS is fairly straightforward with
#media screen and (orientation: portrait) {
img.ri { max-width: 90%; }
}
#media screen and (orientation: landscape) {
img.ri { max-height: 90%; }
}
.image-container {
display: block;
margin: 0 auto 25px auto;
text-align: center;
width: 85%;
}
a.mouseover-thumbnail-holder {
position: relative;
}
.large-image-style {
position: relative;
top: auto; bottom: auto; left: 0; right: 0;
margin: auto;
background-color: #000000;
border-radius: 25px;
border: 10px double #FF0000;
}
a.mouseover-thumbnail-holder .large-image-style {
position: absolute;
display: inline-block;
z-index: 50;
opacity: 0;
pointer-events: none;
top: 50%;
left: 50%;
width: auto;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transition: all 2s ease;
-webkit-transition: all 2s ease;
-ms-transition: all 2s ease;
-moz-transition: all 2s ease;
-o-transition: all 2s ease;
}
a.mouseover-thumbnail-holder:hover .large-image-style , a.mouseover-thumbnail-holder:active .large-image-style {
position: absolute;
z-index: 100;
opacity: 1;
}
All you have to do is use margin: 0 auto; but make sure it has a width on the image
I think this might work for you. Instead of setting position: relative on the a.mouseover-thumbnail-holder element that encloses the image, let the positioning use the root element as the reference point by setting position: fixed on .large-image-style.
If you set all the offsets to zero and then use margin: auto on the image, it will center itself vertically and horizontally in the view port.
.image-container {
display: block;
margin: 0 auto 25px auto;
text-align: center;
width: 85%;
border: 1px dotted blue;
}
a.mouseover-thumbnail-holder .large-image-style {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
opacity: 0;
background-color: #000000;
border-radius: 25px;
border: 10px double #FF0000;
pointer-events: none;
transition: all 2s ease;
}
a.mouseover-thumbnail-holder:hover .large-image-style,
a.mouseover-thumbnail-holder:active .large-image-style {
opacity: 1;
}
.filler {
height: 500px;
border: 1px dotted blue;
}
<div class="filler">Top Filler...</div>
<div class="image-container">
<a class="mouseover-thumbnail-holder">
<img src="http://placehold.it/69x52" />
<img class="large-image-style" src="http://placehold.it/323x244" />
</a>
<a class="mouseover-thumbnail-holder">
<img src="http://placehold.it/69x52" />
<img class="large-image-style" src="http://placehold.it/523x244" />
</a>
<a class="mouseover-thumbnail-holder">
<img src="http://placehold.it/69x52" />
<img class="large-image-style" src="http://placehold.it/323x444" />
</a>
</div>
<div class="filler">Bottom Filler...</div>

CSS slider not workin in IE

I am using a CSS slider on my ebay page (as ebay won't let you upload scripts, etc) but I found that it won't work in IE. Coyldn't figure out how to fix it. Is there a way around it? Or is there a slider with no scripts and that works in IE8+?
Here is the css:
img {
border: none;
}
a {
outline: none;
}
/* Fades in the slideshow. Hides the initial animation on the li tag.*/
#-webkit-keyframes fadeIn {
0% {
opacity: 0;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
ul#slider {
-webkit-border-radius: 10px;
margin: 0px;
padding: 0px;
list-style: none;
position: relative;
width: 700px;
height: 438px;
overflow: hidden;
}
ul#thumb {
overflow: none;
margin: 0px 0px 0px 0px;
padding: 0px;
list-style: none;
position: relative;
background: #000;
overflow: auto;
width: 700px;
}
ul#thumb a {
-webkit-transition: opacity .2s ease-in-out;
border: 1px solid #979797;
width: 70px;
height: 50px;
display: block;
overflow: hidden;
float: right;
margin: 10px 0px 0px 10px;
opacity: 0.75;
}
ul#thumb a:hover {
opacity: 1;
}
ul#slider li {
width: 700px;
height: 438px;
position: absolute;
}
ul#slider li p {
position: absolute;
bottom: -1px;
left: 0;
z-index: inherit;
color: #fff;
background: rgba(0, 0, 0, .5);
width: 100%;
}
ul#slider li p span {
line-height: 0.5em;
padding: 10px;
display: block;
}
/* Animation for the :target image. Slides the image in. */
#-webkit-keyframes moveTarget {
0% {
left:-700px;
}
100% {
left:0px;
}
}
ul#slider li:target {
-webkit-animation-name: moveTarget;
-webkit-animation-duration: .5s;
-webkit-animation-iteration-count: 1;
top:0px;
left: 0px;
z-index: 10;
}
/*
Animation for the current image. Slides it out the frame and back to the starting position.
Adds a lower z-index than the now current image.
*/
#-webkit-keyframes moveIt {
0% {
left:0px;
}
50% {
left:700px;
}
100% {
left:-700px;
z-index: 5;
}
}
ul#slider li:not(:target) {
-webkit-animation-name: moveIt;
-webkit-animation-duration: 1.5s;
-webkit-animation-iteration-count: 1;
top:0px;
left: 0px;
}
And HTML:
<ul id="slider"> <li id="1"> <img src="(image link)" alt="" width="700" height="438" />
</li><li id="2"> <img src="(image link)" alt="" width="700" height="438" />
</li>
<li id="3"> <img src="(image link)" alt="" width="700" height="438" />
</li>
<li id="4"> <img src="(image link)" alt="" width="700" height="438" />
</li>
<li id="5"> <img src="(image link)" alt="" width="700" height="438" />
</li>
</ul>
<ul id="thumb">
<li><img src="(image link)" alt="" width="70" height="50" /></li>
<li><img src="(image link)" alt="" width="70" height="50" /></li>
<li><img src="(image link)" alt="" width="70" height="50" /></li>
<li><img src="(image link)" alt="" width="70" height="50" /></li>
<li><img src="(image link)" alt="" width="70" height="50" /></li>
</ul>
</div>
Maybe you should check out canIuse.com to see browser compatibilities. It could be helpful!
Unfortunately a cross browser, pure CSS image slider is not cur­rently a real­istic option. Using this slider is going to cause issues in earlier ver­sions of Internet Explorer no mat­ter what you do. If you need reas­on­able browser sup­port then you will have to look at a slider that uses Javascript.
All of those -webkit prefixes indicate that whatever CSS you copied and pasted is intended to work only with webkit browsers (Google Chrome, Safari, etc...)
Unfortunately, without webkit, I can't think of many CSS-only gallery solutions.

How to create a horizontal line of three circles

What I'm trying to create
Using HTML5 and CSS3 only, a horizontal row of three circles, each sitting on top of a different image, containing another image and one word of text.
What I have tried
I have tried to create this by just adding divs within divs and specifying heights and widths, but this has not worked. I sense I'm over-complicating something quite simple, or forgetting something very obvious. What is the simplest way of doing this?
A note
Go easy on me! I've been trying to self-learn for only 2 months.
The HTML
<div class="circlewrapper">
<div class="sector" id="read">
<img src="images/test1.jpg" class="image1" height="165" width="165" />
<div class="round" id="reading">
<img src="images/book.jpg" class="image2" height="20" width="20" />
<p id="readread">Read</p>
</div>
</div>
<div class="sector" id="listen">
<img src="images/test2.jpg" class="image1" height="165" width="165" />
<div class="round" id="listening">
<img src="images/book.jpg" class="image2" height="20" width="20" />
<p id="listlist">Listen</p>
</div>
</div>
<div class="sector" id="watch">
<img src="images/test3.jpg" class="image1" height="165" width="165" />
<div class="round" id="watching">
<img src="images/book.jpg" class="image2" height="20" width="20" />
<p id="watchwatch">Watch</p>
</div>
</div>
</div>
The CSS
.circlewrapper {
width: 800px;
height: 270px;
padding: 0px;
margin: 0px auto 0px auto;}
.sector {
width: 250px;
height: 250px;
padding: 0px;
margin: 8px;
display: inline;}
.round {
height: 165px;
width: 165px;
padding: 0px;
margin: 0px auto 0px auto;
background-color: blue;
border-radius: 165px;
-moz-border-radius: 165px;
-webkit-border-radius: 165px;
z-index: 10;}
p {
text-align: center;
color: white;}
.image1 {
margin: 0px auto 0px auto;
padding: 0px;
z-index: 5;}
.image2 {
margin: 0px auto 0px auto;
padding: 0px;}
Add to .sector float: left;. It worked for me.