Improving browser rendering performance
As the web is being used for more and more tasks, expectations rise. Not only should web pages offer rich interaction, they must be responsive in both size and interaction.
This imposes a paradoxon that needs to be solved by building performing applications. It's not enough any more to have your web site do crazy stuff, it is also required to do it crazy fast. This card is intended to give you an introduction to this emerging aspect of web development.
Read this introductory [performance study on Pinterest](http://www.smashingmagazine.com/...
Valuable Chrome DevTools Shortcuts
In the DevTools settings, there's a "Shortcuts" section. Found these keyboard shortcuts there:
General
ESC
Toggle drawer
CTRL + ~ or CTRL + `
Show console in drawer
Styles
SHIFT + up/down
Change number by 10
CTRL + up/down
Change number by 100
Elements
H
Toggle "visibility:hidden!important" (useful when debugging page repaint times)
CTRL + hover above element in the DOM list
Don't show the yellow dimensions tooltip (useful when the tooltip covers just the area you need to see).
Drag...
Angular: Quick and easy animation on changed binding value
With ngAnimate, you can easily animate certain events (see directive support). We'll make use of ngClass
animations to style an element on changed binding value.
Say we have a slider and a separate details container. Each time the slider changes, we want to "flash" the details container by hiding it and fading it back in.
HTML
Add a custom class to the element you want to animate, i.e. the details container:
<div class="details slide-index-{{ currentSlideIndex }}">
{{ co...
CSS has a well-supported :empty selector
All browsers + IE9 know the CSS :empty
selector. It lets you hide an element when it has no content, i.e. not even white space.
(How to prevent whitespace in HAML)
For instance, you have a badge displaying the number of unread messages in a red bubble with white text:
.unread-messages-bubble {
background-color: red;
border-radius: 10px;
padding: 10px;
color: white;
}
To hide that bubble entirely ...
Bootstrap 4 is coming
What's new
- Moved from Less to Sass. Bootstrap now compiles faster than ever thanks to Libsass, and we join an increasingly large community of Sass developers.
-
Improved grid system. We’ve added a new grid tier to better target mobile devices and completely overhauled our semantic mixins.
Opt-in flexbox support is here. The future is now—switch a boolean variable and recompile your CSS to take advantage of a flexbox-based grid system and components. - Dropped wells, thumbnails, and panels for cards. Cards are a brand new co...
Creating spheres with CSS
Using the CSS border-radius property, we can create rounded shapes and circles. Add some gradients and they become spheres. Let’s try that, and add some animation to bring them to life.
An auto-mapper for ARIA labels and BEM classes in Cucumber selectors
Spreewald comes with a selector_for
helper that matches an English term like the user's profile
into a CSS selector. This is useful for steps that refer to a particular section of the page, like the following:
Then I should see "Bruce" within the user's profile
^^^^^^^^^^^^^^^^^^
If you're too lazy to manually translate English to a CSS selector by adding a line to features/env/selectors.rb
, we already have an [auto-mapper to translate English into ...
Bootswatch: Paper
Free Bootstrap theme resembling Material Design.
Bootswatch offers Sass and Less files, so the theme can easily be integrated into your usual Rails application.
Implements only Bootstrap features which means that some Material stuff is missing, but also that you can easily use or replace the theme.
Does not come with extra JavaScript; some effects like button click ripples are implemented via CSS.
Also check out their other themes which can be used in a similar fashion.
List of Helpful RubyMine Shortcuts
Navigation
CTRL + SHIFT + ALT + N
-
Search for any symbol in your application, like CSS classes, Ruby classes, methods, helpers etc.
CTRL + SHIFT + N
-
Search for filename in your application (also dependencies)
CTRL + E
-
Open a list of recently opened files
ALT + POS1
-
Open a the navigation bar as a context menu. Allows you to quickly navigate between files.
CTRL + G
-
Go to line
Actions
CTRL + SHIFT + A
-
...
How to fix: iPad does not trigger click event on some elements
iPads will not trigger click events for all elements. You can fix that, but you don't want to know why.
Example: Capturing clicks on table rows (use case would be clicking the 1st link inside it for better UI). Consider this setup:
<table>
<tr>
<td>hello</td>
</tr>
</table>
^
$(document).on('click', 'tr', function () {
alert('row clicked')
});
While this works on a desktop browser, clicking the row/cell on an iPad will just do nothing.
Turns out, the iPad will only trigger such events for ...
24 little known CSS facts
This blew my mind today:
Please make sure to check browser support for CSS features on Can I Use and the Mozilla Development Network before using.
Favorites
-
outline-offset
: specify how far away from the element an outline is rendered -
::first-letter
: matches the first letter insid...
Material Design Lite
CSS (+ some Javascript) framework, implementing Google's material design for static web pages.
Can be used for plain websites without requiring a full blown Javascript framework, unlike the (also excellent) Polymer paper elements, or Angular material.
Prelimiary impression:
I would recommend against using it at this stage, for a couple of reasons:
- It is much less complete than you might expect from a CSS framewor...
CSS Support Guide for Email Clients
CSS support in major e-mail clients is horrible.
This will give you an overview what you will not be able to use across all clients.
See also
Copy & Paste & The Web | CSS-Tricks
Insanely detailled guide about controlling copy & paste behavior using web technology in 2015.
Note that you can now trigger a copy action through Javascript, no Flash required.
image-to-DataURI converter: Duri.me
Small web application where you can upload an image (PNG, JPEG, GIF) and generate a base64-encoded version of it.
You can copy the result as
- HTML
<img>
tag with data URI, - CSS rule with
background-image
and data URI, - plain Base64-encoded data URI string.
Reverse-proxying web applications with Apache 2.4+
Note: Making a reverse proxy with nginx is much more straightforward.
A reverse proxy is a "man in the middle" server that tunnels requests to another server. You can use for things like:
- Expose a local service that you cannot directly reach over the internet
- "Change" the domain or path of a web application by rewriting them on the fly
- Instantly change servers that respond to a name or ...
Customizable date (and time) picker: Rome
Datetime picker that offers:
- simple UI without a specific framework
- several of customization options
- allows custom date/time validations
Localization happens via moment.js (which is a Dependency anyway).
However, you won't be happy trying to customize it too much:
- It does not support full custom templates, you can only set classes of its elements. If you require extra containers, you are out of luck.
- It offers only a few events, and you can not distinguish if users pick a date, switch to another month, or click outside of the p...
Make "rake notes" learn about Haml, Sass, CoffeeScript, and other file types
Rails comes with a Rake task notes
that shows code comments that start with "TODO", "FIXME", or "OPTIMIZE".
While it's generally not good practice to leave them in your code (your work is not done until it's done), in larger projects you will occasionally have to use them as other parts of the application that you depend upon are not yet available.
To keep track of them, run rake notes
. Its output looks something like this:
$ rake notes
app/controllers/fron...
Fontawesome 4 helper classes
Fontawesome 4 ships with many useful CSS helper classes.
Enlarge Icon
Add fa-lg
(133%), fa-2x
, fa-3x
, fa-4x
or fa-5x
.
Fixed-width Icon
Add fa-fw
. Will give all icons the same width.
Styling Lists
Add fa-ul
to a <UL>
and fa fa-<icon name> fa-li
to a <LI>
to give the list items custom "bullets".
Bordered Icon
Add fa-border
to get a border around the icon.
Spinning Icon
Add fa-spin
to make any icon rotate. Suggested icons: fa-spinner
, fa-refresh
, fa-cog
. Doesn't work in IE <10.
Ro...
Fontawesome 4+ icon naming conventions
Fontawesome 4 has introduced new naming conventions that make it easy to retrieve variants of a given icon.
The format is:
fa-[name]-[alt]-[shape]-[o]-[direction]
Note that this is a naming convention which doesn't imply there's an icon for any combination of tags.
name
The name of the icon, e.g. comment
, print
, bookmark
etc. See the full list.
alt
An alternative icon.
shape
The icon inside a circle
or square
.
o
An outlined ...
Responsive Tables in Pure CSS
Clever hack using data-
attributes to assign labels to cells.
It's still a massive duplication of code (labels), but better and more lightweight than most solutions I've seen for this surprisingly tricky problem.
How to use CSS to rotate text by 90° in IE8 (and modern IEs)
If you want to rotate text, you can use CSS transforms in somewhat modern browsers to rotate the container element.
However, if you need to support IE8, transform
is unavailable (if need only IE9 support, ignore the following and use -ms-transform
).
Here is a solution that worked for me:
<div class="my-element">Hi!</div>
^
.my-element {
display: inline-block;
transform: rotate(90deg);
-ms-writing-mode: tb-rl;
-ms-transform: none;
}
This way, browsers will use CSS transforms when available -- w...
Angular Style Guide
Opinionated Angular style guide for teams by @john_papa
Not everything in this guide works perfectly for us, but is still a good start.
Use CSS sibling selectors instead :last-child (or :first-child)
Often times you want to give a bunch of elements the same style, except for the last. For example borders or margins.
You probably commonly used the :last-child
CSS meta selector like so:
.foo {
border-bottom: 1px dashed #000;
}
.foo:last-child {
border-bottom-width: 0;
}
However, this only works when an element is the last child of its parent. Any other siblings which are unrelated to your case will break it.
Instead, prefer using the +
sibling selector. It applies to the element following the other.
.foo + .foo {
...