CSS Spritesheet animation, clockwise and then anticlockwise - sprite

I want to animate sprite in clockwise and then anti-clockwise continuously.
I am able to do one at a time using two different button.
How can it be done together?
This is what I tried: Codepen
body{
background: #fff;
width: 291px;
margin: 0 auto;
}
.clockwise, .anticlockwise{
color: #000;
cursor: pointer;
font-size: 40px;
font-weight: bold;
font-family: sans-serif;
}
.clockwise{
float: right;
color: #000;
}
.anticlockwise{
float: left;
color: #000;
}
.rotate{
background: url('http://w3bits.com/wp-content/uploads/sprite.png') 0 0 no-repeat;
width: 399px;
height: 200px;
margin: auto;
float: left;
}
.clockwise:hover ~ .rotate{
animation: rotate-clockwise 3s steps(12);
}
.auto{
margin-top: 40px;
color: #fff;
}
.auto:checked ~ .rotate{
animation: rotate-clockwise 3s steps(12);
}
.anticlockwise:hover ~ .rotate{
animation: rotate-anticlockwise 3s steps(12);
}
.auto{
display: inline-block;
margin-left: 0;
}
.auto-rotate{
color: #333;
font-weight: bold;
font-family: sans-serif;
clear: both;
}
#keyframes rotate-clockwise {
0% {background-position: 0 0; }
100% {background-position: 0 -2393px; }
}
#keyframes rotate-anticlockwise {
0% {background-position: 0 -2393px; }
100% {background-position: 0 0; }
}
<input type="checkbox" class="auto" id="auto" >
<label class="auto-rotate" for="auto">Auto ↻</label><br>
<span class="anticlockwise">← A</span>
<span class="clockwise">→ C</span>
<div class="rotate"></div>
Is it possible using only CSS.
Can I flip sprite horizontally to change the direction of cat (sprite) after clockwise and anticlockwise animation ends and then repeat the same.

Not so sure whether this helps, but can't we add all the animations on a single keyframe animation and repeat it infinitely?
I've forked your Pen here and modified it a little: https://codepen.io/mjzeus/pen/oNbGgmP
#keyframes animate-cat {
0% {
background-position: 0 -2393px;
}
20% {
background-position: 0 0;
}
40% {
background-position: 0 -2393px;
}
59% {
transform: scaleX(1);
}
60% {
transform: scaleX(-1);
}
80% {
background-position: 0 0;
transform: scaleX(-1);
}
100% {
background-position: 0 -2393px;
transform: scaleX(-1);
}
}
This is still pretty raw and can be improved a lot but I suppose you'd get the idea what I'm trying to do here. I've just merged all your animations into a single animation and played it on loop.
I hope this helps.

You can flip the cat by adding another class to the (div class="rotate")
.horizontal {
-moz-transform: scaleX(-1);
-o-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
filter: FlipH;
-ms-filter: "FlipH";
}
If you want to automate the process, you would need to add and remove class after fixed time, you can achive this using some JavaScript.
Search for "addClass() Jquery"

Related

How to list Items in rows of 3 in React

I have a list of items that I want to display in rows of 3 but it's not displaying in 3 rows. it works in the normal HTML but doesn't work in React.
Here is my Event Component
const Event = (props) => (
<div className="wrap">
<div className="tile">
<img src={props.event.eventImage} />
<div className="text">
<h1>{props.event.title}</h1>
<h2 className="animate-text">More lorem ipsum bacon ipsum.</h2>
<p className="animate-text">{props.event.description}</p>
<div className="dots">
<span />
<span />
<span />
</div>
</div>
</div>
</div>
);
export default class EventsList extends Component {
constructor(props) {
super(props);
this.state = { events: [] };
}
componentDidMount() {
axios
.get("http://localhost:9000/events/")
.then((response) => {
this.setState({ events: response.data });
})
.catch(function (error) {
console.log(error);
});
}
eventList() {
return this.state.events.map(function (currentEvent, i) {
return <Event event={currentEvent} key={i} />;
});
}
render() {
return (
<div>
<div className="row">{this.eventList()}</div>
</div>
);
}
}
and my css
.wrap {
margin: 50px auto 0 auto;
width: 100%;
display: flex;
align-items: space-around;
max-width: 1200px;
}
.tile {
width: 380px;
height: 380px;
margin: 10px;
background-color: #99aeff;
display: inline-block;
background-size: cover;
position: relative;
cursor: pointer;
transition: all 0.4s ease-out;
box-shadow: 0px 35px 77px -17px rgba(0, 0, 0, 0.44);
overflow: hidden;
color: white;
font-family: "Roboto";
}
.tile img {
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 0;
transition: all 0.4s ease-out;
}
.tile .text {
/* z-index:99; */
position: absolute;
padding: 30px;
height: calc(100% - 60px);
}
.tile h1 {
font-weight: 300;
margin: 0;
text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
}
.tile h2 {
font-weight: 100;
margin: 20px 0 0 0;
font-style: italic;
transform: translateX(200px);
}
.tile p {
font-weight: 300;
margin: 20px 0 0 0;
line-height: 25px;
/* opacity:0; */
transform: translateX(-200px);
transition-delay: 0.2s;
}
.animate-text {
opacity: 0;
transition: all 0.6s ease-in-out;
}
.tile:hover {
/* background-color:#99aeff; */
box-shadow: 0px 35px 77px -17px rgba(0, 0, 0, 0.64);
transform: scale(1.05);
}
.tile:hover img {
opacity: 0.2;
}
.tile:hover .animate-text {
transform: translateX(0);
opacity: 1;
}
.dots {
position: absolute;
bottom: 20px;
right: 30px;
margin: 0 auto;
width: 30px;
height: 30px;
color: currentColor;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
}
.dots span {
width: 5px;
height: 5px;
background-color: currentColor;
border-radius: 50%;
display: block;
opacity: 0;
transition: transform 0.4s ease-out, opacity 0.5s ease;
transform: translateY(30px);
}
.tile:hover span {
opacity: 1;
transform: translateY(0px);
}
.dots span:nth-child(1) {
transition-delay: 0.05s;
}
.dots span:nth-child(2) {
transition-delay: 0.1s;
}
.dots span:nth-child(3) {
transition-delay: 0.15s;
}
#media (max-width: 1000px) {
.wrap {
flex-direction: column;
width: 400px;
}
}
This is how it's displaying.
But this is what I want to achieve.
I am new to React and I'm learning by building a project.
Here is codepen link of what I want to achieve.
Codepen Link
I have a feeling it's your css, you have your wrap class stretching the whole row width and within it, there is a tile that's only 380px.
Consider making row a grid with three columns.
Ciao, you can use display: 'in-line' like this:
return <Event event={currentEvent} key={i} style={{display: 'in-line'}}/>;

Lazy load-style text as seen on new YouTube design?

Can't seem to find what library this is, or anything about it, but I'm seeing it more and more lately. Querying dynamic text via lazyload (with grey bg placeholder). Examples are: cloudflare.com, youtube.com, upwork.com.
Anyone know what it is? Thanks.
No library needed, actually it's really simple and can be done with only HTML and CSS Animation, see the example below.
/*
The javascript here is only for demonstration purpose in order to switch
between 'pulse' and 'wave' animation effect, it is not actually required.
*/
jQuery(document).ready(function ($){
$('#pulse').click(function(){
$('.placeholder').removeClass('wave').addClass('pulse');
})
$('#wave').click(function(){
$('.placeholder').removeClass('pulse').addClass('wave');
})
$('#stop').click(function(){
$('.placeholder').removeClass('pulse wave');
})
});
.placeholder{
margin:15px;
padding:10px;
height: 115px;
border: 1px solid lightgrey;
border-radius: 5px;
}
.placeholder div{background:#E8E8E8;}
.placeholder .square{
float:left;
width: 90px;
height:56px;
margin:0 0 10px;
}
.placeholder .line{height:12px;margin:0 0 10px 105px;}
.placeholder .line:nth-child(2){width: 120px;}
.placeholder .line:nth-child(3){width: 170px;}
.placeholder .line:nth-child(4){width: 150px;}
.placeholder .circle{
float:left;
width: 15px;
height:15px;
margin:0 15px 10px 0;
border-radius:15px;
}
/*
--------------
Pulse effect animation
Activated by adding a '.pulse' class to the placeholder
--------------
*/
.placeholder.pulse div{
animation: pulse 1s infinite ease-in-out;
-webkit-animation:pulse 1s infinite ease-in-out;
}
#keyframes pulse
{
0%{
background-color: rgba(165,165,165,.1);
}
50%{
background-color: rgba(165,165,165,.3);
}
100%{
background-color: rgba(165,165,165,.1);
}
}
#-webkit-keyframes pulse
{
0%{
background-color: rgba(165,165,165,.1);
}
50%{
background-color: rgba(165,165,165,.3);
}
100%{
background-color: rgba(165,165,165,.1);
}
}
/*
--------------
Wave effect animation
Activated by adding a '.wave' class to the placeholder
--------------
*/
.placeholder.wave div{
animation: wave 1s infinite linear forwards;
-webkit-animation:wave 1s infinite linear forwards;
background: #f6f7f8;
background: linear-gradient(to right, #eeeeee 8%, #dddddd 18%, #eeeeee 33%);
background-size: 800px 104px;
}
#keyframes wave{
0%{
background-position: -468px 0
}
100%{
background-position: 468px 0
}
}
#-webkit-keyframes wave{
0%{
background-position: -468px 0
}
100%{
background-position: 468px 0
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="pulse">Pulse Effect</button>
<button id="wave">Wave Effect</button>
<button id="stop">Stop Animation</button>
<div class="placeholder pulse">
<div class="square"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>
The above code is inspired from these articles:
How the Facebook content placeholder works
Loading Placeholder Effect using HTML and CSS

Express-minify cannot load file CSS file. Removing part of it will make it work

I've installed the express-minify middleware but for some reason it seems to cause an error whilst loading the attached css file.
I have tried validating the CSS with an online service and it doesn't give me any error.
I have tried to debug by removing all elements leaving one at the time and when I hit .mainmenu tr td:hover:not(.mainmenu_item_selected) it fails.
So removing everything from .mainmenu tr td:hover:not(.mainmenu_item_selected) to the end of the file will make it work (Obviously without all the other required styles).
I have even tried to recreate the file and also name it differently without any success.
The express logs are showing me: GET /stylesheets/gctl.css 200 4.954 ms - - meaning that the file should be served correctly.
Its a standard installation as per npm website:
var minify = require('express-minify');
app.use(minify());
File (saved as gctl.css)
In main page (Using PUG): link(rel='stylesheet' href='/stylesheets/gctl.css')
CSS file:
html, body, * {
font-family: 'Raleway', sans-serif;
margin: 0;
}
.centered {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
}
.loginform {
text-align:center;
vertical-align:middle;
width: 30%;
height: 50%;
}
.closenewitem {
cursor: pointer;
}
/* Tooltip overide settings */
div.tooltip-inner {
max-width: 500px;
}
/* Remove outlines such as in chrome */
input:focus {
outline: 0;
}
/* all input text align center*/
input, textarea, label {
text-align: center;
cursor: pointer;
font-weight: 400;
}
/* Labels for help add help class to them */
label.help:hover {
color: red;
}
/* Logo CSS */
.logo {
position: absolute;
cursor: pointer;
top: 4px;
height: 40px;
}
/* menu css */
.mainmenu {
border-right-width: 1px;
border-right-style: solid;
border-right-color: lightgray;
margin-left: -15px;
height: 100%;
width: 100%;
}
.mainmenu tr td {
padding: 10px;
}
.mainmenu tr td:hover:not(.mainmenu_item_selected) {
border-right-color: red;
border-right-style: solid;
border-right-width: 3px;
color: black;
cursor: pointer;
background-color: #f0f0f0; /*#f9eafc*/
}
/* Selected menu item */
.mainmenu_item_selected {
border-right-color: black;
border-right-style: solid;
border-right-width: 3px;
background-color: lightgray; /*#f7faff*/
font-weight: 700;
color: black;
}
.mainmenu tr td span {
padding-left: 2px;
}
/* Footer div for additions to DB*/
.footer {
overflow: scroll;
position: absolute;
bottom: 0px;
height: auto;
min-height: 50%;
padding-bottom: 20px;
background-color: #f6f6f6;
border-top-color: lightgray;
border-top-style: solid;
border-top-width: 1px;
width: 100%;
}
.fixed-button {
position: absolute;
top: 4px;
right: 4px;
}
/* Error handling CSS */
.customerror {
border-color: red;
border-width: 2px;
background-color: #ffcccf;
font-weight: bold;
}
/* Shadow only for desktop icons panel as otherwise it would appear everywhere and it's annoying! */
.dsk-panel:hover {
-webkit-box-shadow: -1px 5px 15px 0px lightgray;
-moz-box-shadow: -1px 5-webkitpx 15px 0px lightgray;
box-shadow: -1px 5px 15px 0px lightgray;
}
.desktop-icon {
width: 60px;
opacity: 0.6;
}
I'm stuck and have no clue on what is causing the problem!
If you're sure that the default behavior breaks the Bootstrap layout and there is no issue posted about it yet then you should post an issue on GitHub where this project tracks things like that.
But "breaks layout" doesn't say anything really. Does it change margins? Does it remove borders? What exactly does it break and how? So you should prepare a minimal set of CSS that this module breaks in a predictable manner instead of saying vague claims like that if you want your issue to be taken seriously.
It's entirely possible that you found a bug in this module but it's really hard to tell after an overly general claims like this.

Safari perspective transform cuts off text

So I am trying to add a perspective transform on an element but it is cutting off the text in Safari. If you open the following CodePen in Chrome it displays normally, but in Safari the white text is cut off. I have searched other questions but none seemed to solve my problem.
-webkit-transform: perspective(26.08696em) rotateX(-30deg);
http://codepen.io/anon/pen/aOaNNX
I was facing the same problem today. I fixed the problem setting a transform: translateZ(10px); property to the text that was being cut. Change the value to something that makes sense to you.
.field--name-residential-status {
height: 70px;
width: 100px;
position: relative;
}
.property-status {
display: inline-block;
color: white;
letter-spacing: 0.09375em;
padding: 1.2em 2em;
position: relative;
z-index: 1000;
padding-top: 1em;
text-transform: uppercase;
}
.property-status span {
position: absolute;
z-index: 5000;
-webkit-transform: translateZ(5000px);
}
.field--name-residential-status:before {
display: block;
content: "";
background-color: #2F2F2F;
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
z-index: 2000;
-webkit-transform: perspective(26.08696em) rotateX(-30deg);
-moz-transform: perspective(26.08696em) rotateX(-30deg);
-ms-transform: perspective(26.08696em) rotateX(-30deg);
-o-transform: perspective(26.08696em) rotateX(-30deg);
transform: perspective(26.08696em) rotateX(-30deg);
-webkit-transform-origin: 0% 50%;
-moz-transform-origin: 0% 50%;
-ms-transform-origin: 0% 50%;
-o-transform-origin: 0% 50%;
transform-origin: 0% 50%;
}

Text is not completely being displayed inside a div?

You can see everything in the picture (CSS, the behavior and divs).
The lower part of the p letter and g letter are hidden by the div.
http://img573.imageshack.us/img573/3553/screenshot3m.png
EDIT:
style.css:
/* Structure */
.container {
margin: 0 auto;
overflow: hidden;
width: 960px;
}
#header, #intro, #tagline, #content {
background: url(images/bg.png) top center repeat;
}
#branding, .content, .content-block, .posts, #footer a {
margin-left: 10px !important;
margin-right: 10px !important;
}
#intro h2, #content h2, #nav li a {
text-shadow: 0 1px 0 #FFF;
}
/* Header */
#header {
}
#header a {
color: #333
}
#header a:hover {
color: #28A
}
#branding {
float: left;
margin: 10px 0 10px;
width: 940px;
}
#header h1, #lang {
margin: 20px 0 12px;
width: 280px;
}
#header h1 {
float: left;
width: 280px;
}
#nav {
float: left;
margin: 32px 0 10px;
}
#nav li {
float: left;
}
#nav li a {
font-size: 14px;
font-weight: 400;
margin: 0 40px 0 0;
}
#lang {
float: right;
}
#lang li {
float: left;
}
#lang li a {
font-size: 10px;
margin: 0 0 0 30px;
}
/* Intro */
#intro, #intro2 {
background: #333;
padding: 30px 0;
}
#intro {
height: 400px;
}
#intro2 {
background: #333;
padding: 30px 0;
}
#intro2 h2 {
color: #DDD;
}
...
You can try add css attribute line-height
.content h2{line-height: 35px;}

Resources