CSS Slideshow Using Keyframes works in all browsers except Safari - slideshow

I have no doubt that I'm dealing with my ignorance, but I've got a short code sample for a CSS-based slideshow using keyframes (see JSFiddle (https://jsfiddle.net/puwq00kb/8/) that works with Chrome, FireFox, and IE 11 but NOT Safari (v8.0.6).
Absolutely nothing appears when using Safari, but the images properly cycle for all other browsers. Anyone got a clue what I'm doing wrong?
A series of statements contain images, and timing is controlled via keyframes and nth-child statements.
<div class="RevolvingImages">
<figure>
<img src="http://themarklee.com/wp-content/uploads/2013/10/class-header-css3.jpg" height="262">
</figure>
<figure>
<img src="http://themarklee.com/wp-content/uploads/2013/10/class-header-semantics.jpg" height="262">
</figure>
</div>
The rest is done in CSS. The enclosing DIV simply places the content:
.RevolvingImages {
position: relative;
top: 100px;
left: 40px;
max-width: 350px;
height: 262px;
}
The figures are stacked on top of each other:
.RevolvingImages figure {
max-width: 350px;
height: 262px;
background: #000;
position: absolute;
}
The relative timing is set in CSS in the following manner:
figure:nth-child(1) {
animation: xfade 6s 3s infinite;
z-index:20;
}
figure:nth-child(2) {
animation: xfade 6s 0s infinite;
z-index:10;
}
And the fading between images is done in CSS via keyframes:
#keyframes xfade {
0% {
opacity:1;
}
48% {
opacity:1;
}
50% {
opacity:0;
}
98% {
opacity:0;
}
100% {
opacity:1;
}
}
Thanks!

I stumbled on a solution, but it's ugly (centralization of code is compromised).
In each of the nth-child statements I added a -webkit statement as follows
figure:nth-child(1) {
-webkit-animation: xfade 6s 3s infinite;
-moz-animation: xfade 6s 3s infinite;
-ms-animation: xfade 6s 3s infinite;
animation: xfade 6s 3s infinite;
z-index:20;
}
Also, in addition to the #keyframe section in CSS I added an additional section as follows:
#-webkit-keyframes "xfade" {
0% {
filter:alpha(opacity=100);
opacity:1;
}
48% {
filter:alpha(opacity=100);
opacity:1;
}
50% {
filter:alpha(opacity=0);
opacity:0;
}
98% {
filter:alpha(opacity=0);
opacity:0;
}
100% {
filter:alpha(opacity=100);
opacity:1;
}
}
Similar sections were created for -moz and -ms to cover most browsers.

Related

How to reveal an element (ex. button) after hovering on a certain element of the site?

The problem is I want to make the gray button hidden and get revealed after hovering on a card with hotel pictures.
Currently, I have this site as an example: https://cofffelo.github.io/HotelShop/#
I tried to hide the buttons at their default state by display:none and make it display:block by executing :hover pseudo-index, but because it was hidden from the start, there was nothing to hover, and because I'm kind of a newbie, I ran out of ideas.
The code I tried to add:
.cardbutton{
display: none;
}
.cardbutton:hover{
transform: translateY(30px);
display: block;
background-color: #333;
}
You can use a transition delay
.cardbutton:after {
opacity: 0;
content: "";
}
.cardbutton:hover:after {
opacity: 1;
transition: opacity 0s linear 1.5s;
content: "content text here";
}

translate3d with a transition not being accelerated (being blocked by JS)

I am trying to animate a (100% width) div offscreen by moving it using translate3d(100%,0,0) with a 1s transition. I believe the animation should be fully offloaded to the GPU and not affected by JS, but it is freezing as I do JS computations.
Note that it doesn't freeze when I use a pixel value, e.g. translate3d(500px,0,0)
See this in effect: http://jsfiddle.net/khufzte9/
This is the code I'm using:
CSS:
html, body {
margin: 0;
padding: 0;
}
#blue {
background-color: blue;
width: 100%;
height: 100%;
-webkit-transition: all 1s;
}
HTML:
<div id='blue'></div>
JS:
document.body.addEventListener('click', function () {
var blue = document.querySelector('#blue');
blue.style.transform = 'translate3d(100%,0,0)';
// Do some blocking work after the animation starts
setTimeout(function () {
for (var i = 0; i < 1000000000; i++) {
var j = 5/3;
}
}, 300);
});
Any thoughts or advice would be much appreciated!

drop down with checkboxes in django form

Hi I want to have a dropdown list in my django form with a checkbox in front of every option in the drop down. I have tried using multiple choice field with selectmultiple widget but this displays every option with checkboxes on the page. They are not contained inside the drop down. is there a way to contain them inside the dropdown?
I see that you asked this four years ago so I doubt you are still looking for an answer, but I might as well provide in case someone else finds it!
Basically you want to make a div with an unordered list inside of it, where each item in that list contains a checkbox input.
Then, you use jQuery so that when you click on the div, it gets assigned the 'selected' class in its html.
Then you make your CSS so that the dropdown menu itself only shows up when it has the 'selected' class.
The JSFiddle is here (minus the django templating, obviously):
https://jsfiddle.net/lymanjohnson/2L71nhko/15/
And code is below:
HTML (django template):
<fieldset class="item toggle-item">
<div class="legend-container">
<legend>Choices</legend>
</div>
<ul class="scrollable-dropdown-list">
{% for choice in choices %}
<li>
<input type="checkbox" class="custom-control-input filter" id="choice_{{forloop.counter}}" name="choice" value="{{choice}}">
<label for="choice_{{forloop.counter}}"class="custom-control-label">{{choice}}</label>
</li>
{% endfor %}
</ul>
</fieldset>
JQUERY:
<script>
$(document).ready(function() {
// Listener for when you click on the dropdown menu
$('fieldset.toggle-item > .legend-container').on('click', (event) => {
// Adds or removes the 'selected' attribute on the dropdown menu you clicked
$(event.currentTarget).parent().toggleClass('selected')
// If you have multiple dropdown menus you may want it so that when you open Menu B, Menu A
// automatically closes.
// This line does that by removing 'selected' from every dropdown menu other than the one you clicked on.
// It's 'optional' but it definitely feels better if you have it
$('fieldset.toggle-item').not($(event.currentTarget).parent()).removeClass('selected')
})
// The user is probably going to expect that any and all dropdown menus will close if they click outside of them. Here's how to make that happen:
//This listens for whenever you let go of the mouse
$(document).mouseup(function(e)
{
// make this a variable just to make the next line a little easier to read
// a 'container' is now any
var dropdown_menus = $("fieldset.toggle-item");
// if the target of the click isn't a dropdown menu OR any of the elements inside one of them
if (!dropdown_menus.is(e.target) && dropdown_menus.has(e.target).length === 0)
{
// then it will de-select (thereby closing) all the dropdown menus on the page
$('fieldset.toggle-item').removeClass('selected')
}
});
})
</script>
CSS:
<style>
.item {
width: 33%;
margin: 2px 1% 2px 1%;
border: 0;
}
.item li {
list-style: none;
}
.scrollable-dropdown-list{
position: absolute;
max-height:200px;
width:33%;
overflow-y:scroll;
overflow-x:auto;
margin: 0;
padding-left: 1em;
border-style: solid;
border-width: thin;
border-color: grey;
background-color: white;
}
legend {
margin-bottom: 0;
font-size: 18px;
}
label {
font-weight: normal;
margin-left:20px;
}
.legend-container {
cursor: pointer;
width: 100%;
display: flex;
padding: 0;
margin-bottom: 0px;
font-size: 21px;
line-height: inherit;
color: #333;
border: 0;
border-bottom: none;
}
fieldset {
border-width: thin;
border-color: gray;
border-style: solid;
width:50px;
}
/* Note that all the browser-specific animation stuff is totally optional, but provides a nice subtle animation for the dropdown effect */
fieldset ul.scrollable-dropdown-list {
display: none;
-webkit-animation: slide-down .3s ease-out;
-moz-animation: slide-down .3s ease-out;
}
fieldset.selected ul.scrollable-dropdown-list {
display: block;
-webkit-animation: slide-down .3s ease-out;
-moz-animation: slide-down .3s ease-out;
}
#-webkit-keyframes slide-down {
0% {
opacity: 0;
-webkit-transform: translateY(-10%);
}
100% {
opacity: 1;
-webkit-transform: translateY(0);
}
}
#-moz-keyframes slide-down {
0% {
opacity: 0;
-moz-transform: translateY(-10%);
}
100% {
opacity: 1;
-moz-transform: translateY(0);
}
}
</style>
Dropdowns and checkboxes are HTML elements that are rendered by the browser using its built-in components. Those components don't have any support for combining them: in pure HTML, you simply can't combine a select with a check box.
The only way to do this would be to use components rendered purely in Javascript. Google's Closure UI tools is one set of controls I've used, but only because I used to work at Google: something like jQuery UI might have a version that's easier to use.

Trying to create a css transitition on hover of a h1 class

I have done this before, but it currently is not working and i cant figure out why. I would like the first h1 to rotate on hover just slightly. Here is my code
http://jsfiddle.net/YLXtd/1/
html
<div id="headLine">
<h1 class="fitText"><span class="highLight">Austin Kitson</span></h1>
<h2 class="fitText"><span class="highLight">Marketing & Sales</span></h2>
</div>
</section>
css
#headLine {
position: relative;
top: 10em;
margin-left:auto;
margin-right:auto;
width:100%;
text-align:center;
}
#headLine .fitText {
-webkit-transition: 0.3s;
-moz-transition: 0.3s;
transition: 0.3s;
padding:1em;
}
#headLine .fitText:hover {
-moz-transform: rotate(3deg);
-ms-transform: rotate(3deg);
-o-transform: rotate(3deg);
transform: rotate(3deg); }
#headLine .highLight {
background: rgba(151, 173, 191, 0.7);
padding: 0.3em;
color: #ebe6e0; }
​
ha, turns out I forgot the vendor prefix for safari -webkit-transform: rotate(3deg); and I am using safari, silly me. I do this stuff all the time.
Use this code :
It worked form me
#headLine .fitText {
-webkit-transition: 1.5s all ease;
-moz-transition: 1.5s all ease;
-o-transition: 1.5s all ease;
transition: 1.5s all ease;
}
.fitText:hover {
-webkit-transform: rotate(3deg);
-moz-transform: rotate(3deg);
-o-transform: rotate(3deg);
transform: rotate(3deg);
}
Here is the link http://jsfiddle.net/YLXtd/7/

hardware accelerated css3 animation using -webkit-transform translate3d not working on Samsung Galaxy Tab 10.1

Animation using hardware acceleration CSS3 tags (see code below) works well in Google Chrome PC browser and Android browser on Samsung Galaxy SIII. However, the same does not work on Android browser on Samsung Galaxy Tab 10.1. How to realize hardware accelerated slide in/out animation on Samsung Galaxy Tab device?
<!DOCTYPE html>
<html>
<head>
<style>
#div1
{
border: 1px solid black;
background-color: red;
position: fixed;
left: 0px;
}
#div1.active
{
-webkit-transform-origin: 0% 0%;
-webkit-transition-timing-function: cubic-bezier(0.1, 0.25, 0.1, 1.0);
-webkit-transition-duration:2s;
-webkit-transform: translate3d(-100px,0px,0px);
}
#div1.inactive
{
-webkit-transform-origin: 0% 0%;
-webkit-transition-timing-function: cubic-bezier(0.1, 0.25, 0.1, 1.0);
-webkit-transition-duration:2s;
-webkit-transform: translate3d(0px,0px,0px);
}
#button1
{
position: fixed;
left: 200px;
}
</style>
<script>
var flag = 1;
function myFunction()
{
if (++flag % 2 === 0) {
//alert("active");
document.getElementById("div1").setAttribute("class", "");
document.getElementById("div1").setAttribute("class", "active");
} else {
//alert("inactive");
document.getElementById("div1").setAttribute("class", "");
document.getElementById("div1").setAttribute("class", "inactive");
}
}
</script>
</head>
<body>
<div id="div1">HELLO</div>
<button id="button1" onclick="myFunction()">Click me</button>
</body>
</html>
Kind regards,
Vinaya