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

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

Related

CSS Spritesheet animation, clockwise and then anticlockwise

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"

Position sticky + RTL + Box-shadow breaks on Edge

The following code works well on Chrome, but on Edge the Sticky element is out of place
.main {
display: flex;
max-width: 1200px;
width: 100%;
flex-flow: row nowrap;
margin: auto;
text-align: center;
font-size: 30px;
}
.sticky {
width: 300px;
max-height: 715px;
position: sticky;
top: 10px;
padding: 15px;
margin: 20px 30px 0 0;
box-shadow: 0px 5px 25px 0px rgba(41,128,185,0.15);
background: yellow;
}
.content {
height: 1600px;
flex: 1 1;
background: red;
}
<body dir="rtl">
<main class="main">
<div class="content">Scrollable content here</div>
<div class="sticky">Sticky content here</div>
</main>
</body>
Result in Edge:
I noticed that if I remove the box-shadow from the sticky component or the dir=rtl from the body. It all works as expected.
It appears to be a bug in Edge, and after one resize the window in e.g. jsFiddle, it corrects itself.
What Edge also does, with dir="trl" set on the body, it render the scrollbar on the left side of the viewport, which e.g. neither Chrome nor Firefox does.
A workaround could be to instead of swap position with dir=rtl on the body, use Flexbox's own order property, and then set the direction on the inner elements to control the flow.
Fiddle demo
Stack snippet
.main {
display: flex;
max-width: 1200px;
/*width: 100%; default /*
/*flex-flow: row nowrap; default */
margin: auto;
text-align: center;
font-size: 30px;
}
.sticky {
width: 300px;
max-height: 715px;
position: sticky;
top: 10px;
padding: 15px;
margin: 20px 30px 0 0;
box-shadow: 0px 5px 25px 0px rgba(41,128,185,0.15);
background: yellow;
}
.content {
height: 1600px;
flex: 1 1;
background: red;
order: 1; /* added, move last */
}
<body>
<main class="main">
<div class="content">Scrollable content here</div>
<div class="sticky">Sticky content here</div>
</main>
</body>
Updated based on a comment.
After some more testing and research, trying to move the box-shadow, which obviously cause this issue, to an inner element such a pseudo, still offset the .sticky element.
So two simple solutions, so dir="rtl" can be kept on the body, is to either, using a pseudo, use an image to create the shadow, or, as in below sample, use the filter property.
Here I used a CSS trick to apply it only on Edge, but it can fully replace the box-shadow, and which way to go is more about how old browsers one need to support.
Fiddle demo 2
Stack snippet 2
.main {
display: flex;
max-width: 1200px;
width: 100%;
flex-flow: row nowrap;
margin: auto;
text-align: center;
font-size: 30px;
}
.sticky {
width: 300px;
max-height: 715px;
position: sticky;
top: 10px;
padding: 15px;
margin: 20px 30px 0 0;
box-shadow: 0px 5px 25px 0px rgba(41,128,185,0.15);
background: yellow;
}
/* CSS to target Edge only */
#supports (-ms-ime-align: auto) {
.sticky {
box-shadow: none;
filter: drop-shadow( -5px -5px 15px rgba(41,128,185,0.15) );
}
}
.content {
height: 1600px;
flex: 1 1;
background: red;
}
<body dir="rtl">
<main class="main">
<div class="content">Scrollable content here</div>
<div class="sticky">Sticky content here</div>
</main>
</body>

Nodemailer:HTML not rendering properly

I am using nodemailer to send a welcome mail after registration, the email template is stored in variable
var template = '</!DOCTYPE html><html><head><meta charset="utf-8"><meta http -equiv="X-UA-Compatible" content="IE=8; IE=edge,chrome=1"> <title> Cushbu Art</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css">';
template+= '<style type="text/css"> * {margin: 0; padding: 0; -webkit-box-sizing: border-box; box - sizing: border-box; } p { margin: 0; }';
template+='#font -face{ font - family:"roboto-regular"; src: url("/Roboto-Regular.ttf/"); } body { } main { } . mailer { max - width : 100 %; width: 100 %; margin - left: auto; margin - right: auto; float: left; clear: both; } h2 { font - family: roboto-regular; font - size : 32 px; text - align : center; color: # fff; margin: 0; } h3 { font - family: roboto-regular; font - size : 52 px; text - align : center; color: # fff; margin: 0; } . mailer -head{ width: 100 %; padding: 52px 0; background: url("/mailer-head.png/") no-repeat; background -size: cover; background -color: #fff; } . mailer -body{ width: 100 %; background -color: #fff; float: left; padding: 24px 0; box - shadow : 0 2 px 5 px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); } . mailer -body .logo{ height: 60 px; width: 160 px; margin: auto; display: block; background: url("/logo.jpg/") no-repeat center; background -size: contain; } . para { padding: 24px; max - width : 80 %; margin: auto; } . para p { font - size : 20 px; font - family: roboto-regular; text - align : center; color: # 161616; margin: 0; line - height: 34px; } . container-grid{ max - width : 100 %; margin - left: auto; margin - right: auto; width: 100 %; float: left; clear: both; } . grid - 2{ width: 50 %; float: left; padding: 8 px; } . btn { font - family: roboto-regular; font - size : 15 px; text - align : center; color: # fff; border - radius: 2px; text - decoration: none; padding: 8 px 12 px; background -color: #2066df; } . btn - refer{ float: right; } .btn-upload{ float: left; } .signature{ width: 100%; float: left; clear: both; } .signature p{ font-family: roboto-regular; font-size: 15px; text-align: center; padding: 6px 0; } .signature .sign{ height: 60px; width: 160px; margin: auto; display: block; background: url("/sign.png/") no-repeat center; background-size: contain; } .mailer-footer{ width: 100%; float: left; clear: both; padding: 24px 0; background-color: white; /*border-top: 1px solid #ededed;*/ box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); } .mailer-footer ul{ display: table; margin: auto; padding-bottom: 14px; } .mailer-footer ul li{ float: left; list-style: none; } .mailer-footer ul li a{ height: 47px; width: 47px; line-height: 0; border-radius: 50%; cursor: pointer; vertical-align: middle; margin: 10px; display: block; text-decoration: none; } .mailer-footer ul li a i{ padding: 16px 0; color: #fff; display: block; text-align: center; } .btn-fb { background-color: #3B5998; } .btn-li { background-color: #0082CA; } .btn-tw { background-color: #55ACEE; } .btn-ins { background-color: #3F729B; } .btn-pin { background-color: #C61118; } .btn-gplus { background-color: #DD4B39; } .mailer-footer p{ font-family: roboto-regular; font-size: 15px; text-align: center; }.mailer-footer .p-btm{ padding - bottom: 24px; } . mailer -footer .p-top{ padding - top: 24px; } . mailer -footer span{ font - family: roboto-regular; font - size : 15 px; display: block; text - align : center; } . container-mailer-body{ background: #e5e5e5; float: left; width: 100 %; padding: 0 24 px; clear: both; } footer{ background: #e5e5e5; padding: 10px; clear: both; } footer p { font - family: roboto-regular; font - size : 15 px; text - align : center; } </style></head>';
template+= '<body> <main> <div class="mailer"> <div class="mailer-head"> <h2>Welcome</h2> <h3>user!</h3> </div> <div class="container-mailer-body"> <div class="mailer-body"> <div class="logo"></div> <div class="para"> <p>I am so delighted you have joined us here at www.cushbu.com. Our goal is to create a global platform for artists to exhibit, sell their artworks and worldwide visibility for the International art community. If you are interested in promoting your artworks through our site, instead of the sale, we welcome to do so by an active participation by creating and sharing artworks. We heartily invite you to explore our site with new creative artworks and connect with the talented artists all around the world.</p> </div> <div class="container-grid"> <div class="grid-2"> Refer Now </div> <div class="grid-2"> Ulpoad Art </div> </div> <div class="signature"> <div class="sign"></div> <p>Sanata Balakrishnan</p> <p>COO - Cheif Operating Officer</p> </div> </div> <div class="mailer-footer"> <ul> <li> <a type="button" class="btn-floating btn-small btn-fb" href="https://www.facebook.com/cushbuart/" target="_blank"><i class="fa fa-facebook"></i></a> </li> <li> <a type="button" class="btn-floating btn-small btn-li" href="https://www.linkedin.com/company-beta/13277468/admin/updates/"><i class="fa fa-linkedin"></i></a> </li> <li> <a type="button" class="btn-floating btn-small btn-tw" href="https://twitter.com/cushbuart"><i class="fa fa-twitter"></i></a> </li> <li> <a type="button" class="btn-floating btn-small btn-ins" href="https://www.instagram.com/cushbuartlive/"><i class="fa fa-instagram"></i></a> </li> <li> <a type="button" class="btn-floating btn-small btn-pin" href="https://in.pinterest.com/cushbu/"><i class="fa fa-pinterest"></i></a> </li> <li> <a type="button" class="btn-floating btn-small btn-gplus" href="https://plus.google.com/u/0/communities/112678263549800648922"><i class="fa fa-google-plus"></i></a> </li> </ul> <p class="p-btm">You are receiving this email because you opted in at our website</p> <span>Email your thoughts to,</span> <span>info#cushbu.com</span> <span>contact#cushbu.com</span> <p class="p-top">You are receiving this email because you opted in at our website</p> </div> </div> </div> </main> < footer> < p > Copyright © 2017 Cushbu Art Pvt Ltd rights reserved</p> < / footer></body ></html>';
Email sending code
var transporter = nodemailer.createTransport({
host:'XX',
port :465,
secure: true,
auth: {
user: 'XX',
pass: 'XX'
}
});
var mailOptions = {
from: '<sender>', // sender address
to:'me#me.com', // list of receivers
subject: 'Welcome', // Subject line
html:template
};
transporter.sendMail(mailOptions, function(error, info) {
if (error) {
res.send(error);
return console.log("Error ",error);
}
res.send('Message %s sent: %s', info.messageId, info.response);
});
But the problem is email is not rendering the HTMl properly styles are missing
I'm not an authority on this, but I'm fairly sure the html payload of an email is supposed to be a lot simpler than a full document. Whether or not it gets rendered, and how complicated the styles can be is really up to the client that the receiver is using to view the email (gmail, thunderbird, etc, etc).
I'd use a couple rules of thumb for sure:
Don't expect anything from the <head> element to be included. I'd even leave out the <body> and just use a <div> or <p> or <table> as your root element.
Put styles either directly on your elements, or in a <style> tag - not in the <head> as that will likely be excluded.
No links to local resources! I think you're trying to grab a font from a relative url. Best to avoid all external resources if you can, but if you must, absolute urls may work.
The simpler the better.
You can really do a lot with just a few styles in an email. If you really need your branded font, just create a logo image that features it. Nodemailer has some cool tricky ways to include your images as attachments so they don't count as external resources and are less likely to be blocked. (I can't find the docs, but here is a quick guide).
External files dont seem to work with nodemailer,
You are referencing a CSS file, you need to make all those styles inline

Chrome 43 Flexbox flex-grow issue

Before Chrome 43, div1 would take up 10% of the container height regardless of its childrens size, and div1 would overflow. As of Chrome 43 div1 doesnt follow flex-grow anyone more and instead grows to its childrens size. Is this supposed to work this way? How do i get div1 to overflow and follow its flex-grow property. Thanks!
Heres a jsfiddle: http://jsfiddle.net/HorseFace/xsbmmf4o/
<div id="container">
<div id="div1">
<div id="inner1"></div>
</div>
<div id="div2">
<div id="inner2"></div>
</div>
</div>
#container {
height: 500px;
display: flex;
flex-direction: column;
}
#div1 {
background: red;
flex-grow: 0.1;
}
#inner1 {
height: 200px;
background: lightcoral;
}
#div2 {
background: blue;
flex-grow: 0.9;
overflow: auto;
}
#inner2 {
height: 200px;
background: #ccccff;
}
body {
color: purple;
background-color: #d8da3d
}
You are misunderstanding flex-grow. It sets the flex grow factor,
which determines how much the flex item will grow relative to the rest of the flex items in the flex container when positive free space is distributed. When omitted, it is set to 1.
So only free space space is distributed. If you want that flex item to take up 10% of the flex container, you should set the flex-basis to 0:
the flex basis [is] the initial main size of the flex item, before free space is distributed.
Note you can use the shorthand flex property to set both flex-grow and flex-basis simultaneously (and flex-shrink too):
flex: 0.1; /*
flex-grow: 0.1;
flex-shrink: 1;
flex-basis: 0;
*/
Also note that the Flexbox spec changed the initial value of min-height and min-width to auto (previously it was 0). This may break your percentages, so either use overflow different than visible, or set min-height: 0.
body {
color: purple;
background-color: #d8da3d
}
#container {
height: 500px;
display: flex;
flex-direction: column;
}
#div1, #div2 {
min-height: 0; /* Or `overflow: hidden` */
}
#div1 {
background: red;
flex: 0.1;
}
#inner1 {
height: 200px;
background: lightcoral;
}
#div2 {
background: blue;
flex: 0.9;
overflow: auto;
}
#inner2 {
height: 200px;
background: #ccccff;
}
<div id="container">
<div id="div1">
<div id="inner1">Inner1</div>
</div>
<div id="div2">
<div id="inner2">Inner2</div>
</div>
</div>

Slide out sidebar in Blogger

I'd like to have my sidebar slide out of my blog with the click of a button. I've only been able to find this for Dynamic Views but surely it can be done with the right code! My site is bhyphen.com and any help would be greatly appreciated!
It's actually quite simple.
This is how I did it in my static magazine template. You can check out a live preview of what the sidebar looks like here: http://kreatief-staticmagazinetemplate.blogspot.ch/
First you need to add a new section:
<div id='sidebar'>
x
<b:section class='sidebar' id='sidebarsection'>
</b:section>
</div><!--/sidebar-->
<a class='toggle-link' href='#sidebar'><i class='fa fa-plus fa-lg'/></a>
So we have a container and a anchor, which will toggle the sidebar.
Then register the section so that you can add widgets to it.
I do use font-awesome in the button, so place
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
within the <head> of your page.
When the button is clicked, we will toggle an active class on the menu, so for that I used a little bit of jQuery (it's best if you search for the closing body tag (</body>) and add the following directly above.
<!-- jQuery -->
<script src='//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'/>
<!-- toggle active class -->
<script>
//<![CDATA[
$(document).ready(function(){
$(".toggle-link").click(function(){
$("#sidebar").toggleClass("active");
$(".toggle-link").toggleClass("active");
});
});
//]]>
</script>
Then just finish off with CSS.
Place that in the CSS section, above ]]></b:skin>
I did already write the variable definition for the template designer, so I'll just add it as well, put that to the other variable definitions
<Group description="Sidebar and Toggle" selector="#sidebar, .toggle-link">
<Variable name="sidebar.bg" description="Sidebar Background Color" type="color" default="#ffffff" value="#ffffff"/>
<Variable name="sidebar.border" description="Sidebar Border Color" type="color" default="#333333" value="#333333"/>
<Variable name="box.link.color" description="Box Link Color" type="color" default="#ffffff" value="#ffffff"/>
<Variable name="box.link.bg" description="Box Link Background" type="color" default="#333333" value="#333333"/>
<Variable name="box.hover.bg" description="Box Link Hover Background" type="color" default="#000000" value="#000000"/>
</Group>
If you don't want to use the variables, just replace all of the variable names with colors of your choice.
/* Sidebar
/*-------------------------------*/
#sidebar {
position: fixed;
top: 0;
bottom: 0;
width: 300px;
right: -304px;
height: 100%;
-webkit-transform: translate(0px, 0px);
transform: translate(0px, 0px);
-webkit-transition: 0.3s ease;
transition: 0.3s ease;
background-color: $(sidebar.bg);
border-left: 4px solid $(sidebar.border);
z-index: 15;
overflow-y: auto;
}
.sidebar{
width: 90%;
padding: 0 5% !important;
}
.widget{
max-width: 100%;
}
.toggle-link.active,
#sidebar.active {
-webkit-transform: translate(-304px, 0px);
transform: translate(-304px, 0px);
-webkit-transition: 0.3s ease;
transition: 0.3s ease;
}
.toggle-link.active i{
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transition: 1s ease;
transition: 1s ease;
}
.toggle-link {
position: fixed;
top: 150px;
right: 0px;
width: 30px;
height: 30px;
background: $(box.link.bg);
text-align: center;
line-height: 30px;
padding: 5px;
-webkit-transition: 0.3s ease;
transition: 0.3s ease;
z-index: 15;
color: $(box.link.color);
}
#sidebar .toggle-link {
display: none;
}
#media screen and (max-width: 350px){
#sidebar .toggle-link {
display: inline;
position: relative;
top: 0;
right: -270px;
padding: 5px 10px;
}
}
.toggle-link:hover {
background: $(box.hover.bg);
}
.toggle-link i {
-webkit-transition: 1s ease;
transition: 1s ease;
color: rgba(255, 255, 255, .8);
}
And that's it.

Resources