CSS Double Borders Using Box-Shadow

Every now and then you may come across a design that calls for double borders around an element. The “border” CSS property only gives you one border. Instead of wrapping your element in a div and applying another “border” property to it to give the effect of two borders, you can use the “box-shadow” CSS property and setting the thickness of one border to be larger than the other. Copy and paste the code below and adjust accordingly.
[cc lang=”css”]
box-shadow: 0 0 0 1px #ededed, 0 0 0 2px #dfdfdf;
[/cc]
Note: The “box-shadow” property doesn’t work in IE 8.

 

Email-Safe Fonts for HTML Email

There are two jokes in the web design community. The first one goes like this:

 A web designer walks into a bar and immediately leaves in disgust upon noticing all of the tables.

And here is the second.

HTML Email.

Basically, HTML emails are a b@#4ch!  If you want your fonts to look as you’d expect in your HTML emails, use one of the following.

email-safe-fonts

Fixed Width; Fluid Backgrounds Using a Single Element

Sometimes you may need a layout that calls for fixed width content but a fluid background. You can accomplish this with multiple divs or, if you use the calc function, you can just use one div or element, as exemplified below.

[cc lang=”html”]

This content is 200 pixels wide and wraps after it reaches 200 pixels.

[/cc]

[cc lang=”css”]
div.section {
width: 200px;
padding: 0 calc(50% – 100px);
background-color: blue;
color: white;
}
[/cc]

See the demo at jsfiddle.

Canned Messages Using AutoHotKey

Sometimes you may come across a situation where you need to keep typing the same message over and over again like when you’re replying to customer emails. Most people would save different messages in a text editor like Notepad and use copy and paste to avoid having to retype their messages. However, there’s an even easier way using a Windows program called AutoHotKey. With AutoHotKey, you won’t have to switch windows and copy and paste text. You can create a simple script in a text file and assign it to a certain key and when you click on the key (or combination of keys), the text you saved will be written to where your cursor is (in a text area). Here’s an example script in a file called AutoHotKey.ahk in my Documents folder:

#F1::
Send Thank you for your order. {Enter} Please reply indicating which two kites colors you want. We have blue kites, red kites, and purple kites.
return

Continue reading Canned Messages Using AutoHotKey

Website Image Optimizer / Pre (post?) Processor

Let’s face it. The biggest loads and cause for slow performance of most websites comes from images. While there are many projects that offer automated ways to optimize and process CSS like Sass and Less, these optimizations result in a much smaller performance gain compared to what you get from optimized images. The problem with optimizing images is finding a balance between optimization and maintainability. You want to use sprites to minimize the number of requests but you want to reuse images in multiple pages to simplify maintenance (not have multiple copies of the same image). Assuming that most people view 2 or 3 pages per website during any visit, following is a proposal for an image optimization algorithm. This algorithm would generate two types of image sprites as follows:

  • global.png / global.jpg (for images that appear in all pages, e.g. in the header and footer like the website logo)
  • page-path.png /page-path.jpg (for images that appear in a single page, e.g. about-us.png, about-us.jpg, products-computers.png, products-tvs.jpg, etc)

If a web page is at the URL www.somedomain.com/products/computers/index.html, then the sprite for that page would have the file name products-computers.png and/or products-computers.jpg (slashes are converted into dashes). Continue reading Website Image Optimizer / Pre (post?) Processor

Website Performance: How Heavy are Your Images?

Images in websites help break up long, boring passages of text and make websites look nice. But, they’re also the heaviest resources you can include in your site.  Let’s take the home page of techcrunch.com as an example. With the Google Chrome inspector open to the Network tab and the Images label selected, we load the page and scroll all the way to the bottom (because images are load dynamically as they appear in the viewport). The result in 6.5 MB out of a total of 7.3 MB of data to load the home page came from images alone. That’s a whopping 89% of the page load. Because the images are loaded dynamically as needed, techcrunch.com doesn’t load too slowly. However, there are still many websites that are image heavy and don’t do a good job at optimization or caching at all.

page-load