Demo: Using CSS3 to create a rounded corner box

As the CSS3 specification continues to take the web by storm, more and more browsers are

With CSS3, much of the slicing work that used to be the norm back in the ‘old’ CSS2/2.1 days is become much less of a necessity. What used to take multiple (background) images to create a rounded corner, drop shadow or gradient effect can now be easily and quickly done with CSS3.

This was a pain on many levels – front-end developer notwithstanding! For example, to create a layout for the feature box mock-up shown below, you would be look (at the bare minimum) four background images:

  • Header gradient
  • RSS icon
  • Rounded-corner box
  • Rounded-corner button

Example of a rounded-corner "feature" box

If you wanted a fluid-width box, there would be extra markup required (<div> element for each corner of the box) and this would also mean extra background images to compensate for this (unless you combined the images into a sprite). Or, if you went with a static-width implementation, you would be forced to create additional images if you wanted to use a smaller or larger version of the box.

Talk about a time consuming and potentially frustrating experience, but that’s the way things were and we got used to it.

However, with CSS3 support coming soon to a browser near you, the way design elements, like the one in the example above, are handled can be done in a completely different – dare I say ‘smart’ way! Using the aforementioned example, I created a nearly identical version of it using only CSS and only one background image (RSS icon). This has been styled to be a fixed width, but changing that requires nothing more than a tweak to the width property of the parent wrapping element.

A screenshot of what the resulting box looks like:

CTC_FeatureBoxCSS3

As you can see, its not as nice looking as the Photoshop version (from the first screenshot), but pretty close.

A demo of the HTML/CSS that was used to generate the box above can be viewed here.

In terms of full support across all the top browser manufacturers, we are not there yet, but we are getting closer and I expect that in a couple of years this will be the standard (CSS3) that all the current browsers will meet.

Posted in Labs | Tagged , , , , , | Leave a comment

Site Launch: Council of Turkish Canadians

Today marked the launch of a redesign of the Web site for the Council of Turkish Canadians.

Screenshot of the Home page of Council of Turkish Canadians

The site was built using WordPress which gives the content manager the flexibility to be able to easily manage the Web site’s content from within the administrator area of WordPress (Dashboard).

The site was built using Pages with the News and Other News items being Posts. To differentiate the two types of news items, I assigned categories to each and then used that for filtering the results when displaying news items on the Home and News pages.

The rest of the functionality of the site was accomplished via third-party plugins – specifically the items which appear in the sidebar, including:

  • Events
  • Join Our Mailing List
  • Buy Books at Amazon.ca

Events

For the Events – which appears in the sidebar of the Home page and also in the Events section of the site – a plugin called "Events Manager” by Davide Benini was used.

I was very pleased with the customization and functionality that the plugin offers – definitely one of the better ones I’ve seen. There are a good number of short/template tags made available by the plugin, so showing a list of events (past, future or all) on any given page/post is a simple process.

Managing events, from within the WordPress Dashboard, is also a simple and straightforward process. What would normally be a time consuming and arduous task is made simple with Events Manager.

Join our Mailing List

The mailing list is a very simple one-field form that captures a user’s email address. Instead of developing a custom form ourselves to handle this, we instead went the plugin route – mainly due to the fact that this site will be housing at least one more form that will contain a number of fields. Instead of having to create an additional custom form, it made better sense to get a plugin that would allow the user to easily manage/build this – rather than having to create something from scratch.

We used a pluign called Gravity Forms. Gravity Forms allows you to create functional forms easily using a drag-and-drop interface. It doesn’t offer you a whole lot of customization options, but rather keeps things minimal in order to make the process as easy as possible for the end user.

My only gripes with this plugin was that it didn’t offer any methods of allowing custom HTML to be inserted within the form. Also, customizing the validation messages – and the location where they are displayed – was also a no go.

Buy Books at Amazon.ca

Lastly, the plugin we used for the Amazon widget (bottom of the right-hand sidebar) was Amazon Showcase. Like the other two (plugins), implementing this was painless and easy. Adding a book to the showcase is as simple as entering in the book’s ISBN number and then selecting a thumbnail size to use for displaying the cover of the book.

Posted in Portfolio, Worklife at High Road Communications | Tagged , , , | Leave a comment

Site Launch: World Hepatitis Alliance

This past week we launched a Web site redesign for the World Hepatitis Alliance.

Screenshot of the Home page of the redesigned World Hepatitis Alliance Web site

The World Hepatitis Alliance is a non-governmental organisation that represents approximately 280 hepatitis B and C patient groups from around the world. As a coalition of advocacy groups, the World Hepatitis Alliance is a global voice for the 500 million people worldwide living with chronic viral hepatitis B or C.

This was a large undertaking due to the amount of content and functionality that was required, including:

The architecture that this Web site was built on was Sitefinity, and again it was a case where were extremely happy with the choice in using this production for our site build. The majority of our custom development (based on the required functionality in the list above) were either based or used existing controls that come packaged with the CMS.

During the development we built a custom tool for handling the social media aspect of the site. It works like Yahoo! Pipes but adds an extra level of manageability to allow a content manager the ability to approve each content piece that comes through the ‘pipe’ before its made available to the Web site.

Props go to Kris Blazejewicz, a Senior Developer here at High Road Communictions who was the lead in developing this application.

Posted in Portfolio, Worklife at High Road Communications | Tagged , , , , , | 1 Comment

Inline-Block whitespace workaround

In response to an article written yesterday (April 26th, 2010) about the inline-block display property on Impressive Webs, there was some debate on unwanted whitespace that appears to the right of elements that are styled with this property.

If you use inline-block there are some important factors and drawbacks to keep in mind. An inline-block element is white-space dependent, so if you display list items using inline-block (in a navigation bar, for example), the list items will have unwanted space next to each other.

This is an issue that seems to occur in most modern browsers – including IE8 and most versions of Firefox, to name just a couple. The workaround for this problem is actually pretty simple and does not require any crazy HTML markup hacks, as was shown on the site I mentioned above.

First of all, it is important to note that the amount of whitespace that appears to the right of an element that has a display property of inline-block is 4 pixels. Sounds easy to fix, right? Just apply a negative margin-left property of -4px and we’re done, right? Well, not so easy – first, not every browser* applies this 4 pixel gap – and – if the element is marked up as shown below, there will be no whitespace added period – regardless of what browser you are using:

<ul>
	<li>Item One</li><li>Item Two</li><li>Item Three</li><li>Item Four</li><li>Item Five</li>
</ul>

*NOTE: IE6 and IE7 do not understand the inline-block property and as such require additional properties of display: inline and zoom: 1 (zoom is used to force hasLayout) in order for them to mimic inline-block. As such, the 4 pixel gap does not get applied to the elements.

The solution then is to apply the rarely-used letter-spacing property and give it a negative value that is equal to the width of the whitespace gap, which in this case if 4 pixels. The property must be applied to the parent element, using our example above, it would be applied to the <ul> tag.

ul {
	letter-spacing: -4px;
}

Finally, you need to ‘undo’ the negative spacing on each of the inline-block elements so that the text contained within does not get affected by the property we set on it’s parent.

ul {
	letter-spacing: -4px;
}
	ul li {
		letter-spacing: normal;
		display: inline-block;
		*display: inline; /* For IE6/IE7 */
		zoom: 1; /* For IE6/IE7 */
	}

I’ve tested this across IE6-IE8, Chrome, Firefox (v3+) and Safari (v4) and it seemed to be working properly. However, when I tested in Opera (v10), the whitespace gap was still there. The fix for this was to apply a word-spacing property to it, using the same value as before:

ul {
	letter-spacing: -4px;
	word-spacing: -4px;
}
	ul li {
		letter-spacing: normal;
		word-spacing: normal;
		display: inline-block;
		*display: inline; /* For IE6/IE7 */
		zoom: 1; /* For IE6/IE7 */
	}
Posted in CSS, Quick Tips | Tagged , , | 2 Comments

Quick tip: Disabling inline JavaScript within Sitefinity “edit” mode

This is a handy little workaround I found for a small issue I was having within the CMS of Sitefinity. Pages that have some form of custom JavaScript functionality can sometimes play havoc with Sitefinity when in “edit” mode.

For example, I have a page that uses JavaScript to hide or show content based on options set from an image map. On page load, the content is set to be hidden, so when I go into Sitefinity to edit the page, the JavaScript functionality is getting run and thus all I get is an empty Generic Content control (where all my content has been placed). Not the biggest deal in the world, but it can be confusing for a client as they are not seeing the content that they are expecting to see. Further to my point, in this example there are a number of Generic Content controls on the page, so figuring out which one contained the content I wanted to modify was anybody’s guess!

That’s when I came up with this quick and easy workaround. Any JavaScript that you wish to be disabled within the Sitefinity CMS should be wrapped in the following if logic statement:

$(function() {

	if($('meta[name="Generator"]', 'head').size() > 0) {

		// Statements you wish to 'fire' when not in Sitefinity edit mode.

	}

});

On the public view of each Sitefinity-generated page, there is a meta tag created called “Generator” which contains the current version (value attribute) of Sitefinity that is being run, as shown in the following example:

<meta name="Generator" content="Sitefinity 3.7.2022.2:2" />

This meta tag does not get rendered when editing a page within Sitefinity. With this in mind, I simply check for it’s presence, and if it’s ‘found’, run the desired JavaScript statement. Otherwise, the JavaScript will not run and the content will be rendered as you (or more importantly, the client) would expect.

Posted in Quick Tips | Tagged , , | 1 Comment