Thursday, July 21, 2016

Decoding CSS Positioning: A Master Class with Paul O’Brien

CSS Positioning with Paul O'Brien

Positioning elements on a web page can seem maddeningly difficult at times, especially given all the various methods available. And the options continue to expand, with the introduction of flexbox and grid layouts, as well as cool things like CSS3 transforms, which can also be used for amazing layout tricks.

In this forum dCode, CSS expert Paul O'Brien answers anything and everything about the tricky subject of CSS positioning --- from floats and relative, absolute and fixed positioning to table display and even flexbox.

If you have any questions about CSS positioning, please join the conversation!

About dCodes

Our Forum dCodes are topics that feature a guest who conducts a deep dive into a subject area. Unlike our Q&A sessions, which run for just an hour, dCode topics stay open over a long period, so that issues can be discussed at greater length and in greater depth. You can ask questions, or just sit back and follow along, over time, as the guest answers questions and posts content of interest.

Continue reading %Decoding CSS Positioning: A Master Class with Paul O’Brien%


by Ralph Mason via SitePoint

Translating CSS for Paged Media with Rachel Andrew

Last week we spoke with Rachel Andrew, a CSS Working Group Invited Expert, and Founder of Edge of my Seat. Rachel is passionate about CSS, and that passion has clearly made her stand out as a master of her craft, especially when working with paged media. She has even worked with us to produce our own book layouts here at SitePoint — all with CSS! CSS for paged media is such a niche topic, and this is exactly the reason that we were blown away when Rachel decided to join us for a Q&A to answer your questions. Let's dig in!

Continue reading %Translating CSS for Paged Media with Rachel Andrew%


by Angela Molina via SitePoint

Crazy Things Happens in One Second of the Internet - infographic

Crazy Things Happens in One Second of the Internet - infographic

Have you ever thought, “What is the importance of one second?” Doesn’t seem that important, right? You blink your eye and poof!! It’s gone. That’s true normally, but when it comes to the World Wide Web, one second is extremely crucial as a lot of crazy data flows through it in the blink of an eye.

If the servers of Amazon, Flipkart or any other e-commerce giant stay down even for a second, it results in a loss of hundreds of thousands of dollars.

Don’t believe it, here is a fact that’ll blow your mind. In 2014, Amazon’s site was down for a mere 49 minutes and the company lost $4.8 million. Crazy, right?

So, now allow us to explain you the value of a second on Internet. Here are some crazy facts that will make you look at the tiniest measure of time in a new light:

• Amazon and eBay get approximately $3400 and $680 worth of transactions within a second. Also, Amazon ships around 35 items in a second

• 2,488,887 e-mails get sent within a second on the internet

• 22 new WordPress posts are made

• 1160 Tumblr posts are made

• 54,319 Google searches are made by people across the globe in a second

by Irfan Ahmad via Digital Information World

Getting Started With Vue.js

Vue.js is a JavaScript library that helps you build web applications that conform to the MVVM (Model-View-ViewModel) architectural pattern. At first glance, it might seem quite similar to AngularJS, but once you start working with it, you’ll quickly realize that Vue.js is not only much simpler and easier to learn, but definitely more flexible.

In this introductory tutorial, I’ll teach you the basic concepts of Vue.js, trying to do a complete overview of its most important features.

Adding Vue.js to Your Page

Though you can get the latest release of Vue.js from GitHub, you would find much easier to load it from a CDN. Here’s the procedure to load it from cdnjs:

Continue reading %Getting Started With Vue.js%


by Ashraff Hathibelagal via SitePoint

jQuery Web Ticker

Web Ticker is a jQuery plugin that allows you to have items scrolling indefinitely across the screen. It uses some fancy calculations to ensure smooth continuous transitions.


by via jQuery-Plugins.net RSS Feed

Enhance Your WordPress Comments with a Mention Feature

Many WordPress sites allow visitors to share comments on blog posts. There are several WordPress plugins that also enable visitors to leave a reply to comments. However, this process can get confusing when more than one author is replied to or referenced in the comment.

In this tutorial, I’ll be covering how to write a handy WordPress plugin that brings a Twitter-like mention feature right into our WordPress site, to allow readers to tag each other in comments.

At the end of this tutorial, I’ll provide a link to download the plugin which also has some additional features and a link to view the plugin on GitHub.

Continue reading %Enhance Your WordPress Comments with a Mention Feature%


by Doyin Faith Kasumu via SitePoint

Visual Regression Testing with PhantomCSS

If you've done any serious development in your career you've likely reached the point when you realized the importance of automated testing during development. Depending on your experience, this realization might hit you in one big burst or it may gently come to you over time, but it will eventually become second nature. Automatic testing comes in many forms, from unit testing, when you test isolated pieces of code, to integration and functional testing, when you test how different parts of your system behave together. This article is not about an overview on automatic testing in general. It is about a particular and a relatively new niche referred to as visual regression testing.

Visual regression testing takes an alternative approach to testing web pages. Instead of just making sure that some element or a text value is present in the DOM, the test actually opens the page and checks if this specific block looks exactly like you want it to. Just to make sure that you picked up the difference, let me give you an example. Imagine, that you want your website to greet your visitors with a friendly message:

[code language="html"]
<div>Hello, %username%!</div>
[/code]

To make sure it works, you can (and should) unit test the piece of code that produces the message, checking that it inserts the correct name. You can also write a functional test using Selenium or Protractor to see if the element is actually present on the page with the correct text. But this is not enough. We want to test not just that the text is generated correctly or appears in the DOM but to make sure that the whole element looks correct, i.e., making sure that the element is not hidden by display: none or that someone hasn't accidentally overridden the color of the text. There are a number of tools to do that, but today we will be looking at one option in particular — PhantomCSS.

What is PhantomCSS?

PhantomCSS is a Node.js tool to perform visual regression testing. It is open source and developed by the guys at Huddle. PhantomCSS allows you to run a headless browser, open a page and take a screenshot of the whole page or a particular element on the page. This screenshot will be stored as a baseline image for future reference. Whenever you change anything on the website, you can run PhantomCSS again. It will take another screenshot and compare it to the original image. If there are no differences found, the test will pass. If, however, the screenshots don't match, the test will fail and a new image showing the difference will be created for you to review. This approach makes this tool perfect for testing changes in CSS.

PhantomCSS is built on top of several key components:

  • CasperJS - a tool for interacting with a PhantomCSS or SlimerJS browser. It allows you to open a page and perform user interactions, such as clicking on buttons or inputting values. Additionally, CasperJS provides its own testing framework and the ability to capture screenshots of a page.
  • PhantomJS 2 or SlimerJS - two different headless browsers, either of which can be used with PhantomCSS. A headless browser is just like a normal browser without a user interface.
  • Resemble.js - a library for comparing images.

PhantomCSS can be used together with both PhantomJS and SlimerJS, but in this article, we'll be using PhantomJS.

Let's Take It for a Spin

Let's set up a tiny test project to see how we can use this tool in practice. For that, we'll need a web page to test and a simple Node.js web server for CasperJS to be able to open the page.

Setting up a Test Project

Create an index.html file with some sample content:

[code language="html"]
<!doctype html>
<html>
<head>
<style>
.tag {
color: #fff;
font-size: 30px;
border-radius: 10px;
padding: 10px;
margin: 10px;
width: 500px;
}

.tag-first {
background: lightcoral;
}

.tag-second {
background: lightskyblue;
}
</style>
</head>

<body>
<div class="tag tag-first">The moving finger writes, and having written moves on.</div>
<div class="tag tag-second">Nor all thy piety nor all thy wit, can cancel half a line of it.</div>
</body>
</html>
[/code]

Continue reading %Visual Regression Testing with PhantomCSS%


by Pavels Jelisejevs via SitePoint