1st May 2009

Introducing Ionic, a CSS framework put together to specifically handle layouts with more than 2 columns in CSS.

The framework, originally written by Jason under the name ‘fluid1′, has been used on our client’s website, IEMA.net, since 2005. The aim of the project was to make it accessible to all the common browsers, whilst keeping the HTML markup as semantic as possible.

Currently the script only supports a maximum of 3 columns, but there is no reason why the algorithm can’t be extended to support any number of columns.

Ionic has its own microsite under development where you’ll be able to grab the latest releases and find out more about the framework. The link is:
www.consil.co.uk/ionic.

Tags: , ,

7th April 2009

A tutorial for producing these maps will be provided soon. With the help of InkScape and a spreadsheet, they are not quite as fiddly as you would expect. Each map consists of a single image, with all the roll-over images as a part of the main map image.

It uses a ‘sprite’ technique to move the roll-over background images into position when the mouse hovers over the [square] regions. Why do it like this? Firstly there is no JavaScript involved. Secondly it keeps the number of objects downloaded to a minimum – just one stylesheet (or set of styles) and one image. Lastly, it degrades nicely to a simple unordered list when CSS is not available or relevant.

Half Size

Continue reading »

Follow me on Twitter

Tags: , ,

29th December 2008

clearing-floats-29dec08To anyone out there reading up on clearing, this is the best method:

http://www.positioniseverything.net/easyclearing.html

It’s totally cross-browser compatible, doesn’t leave any messy markup and leaves the code fully accessible. It does however have 1 flaw…

Scroll down to the part about the IE/Mac problem and you’ll see the fix involves adding a display: inline-block to the container block, which is then re-instated to a display: block in the IE stylesheet.

The problem is that inline-block also affects all the other non-IE browsers. This gives us a wrapper that’s not 100% wide. So what can we do?

Initial Setup

The following example will work on every modern browsing environment except Internet Explorer on Macs. You may just want to leave it like this and not bother accommodating the ancient browser.

MyPage.html

<html>
<head>
   <link rel="stylesheet" type="text/css" href="main.css" media="screen" />
   <!--[if IE]>
      <link rel="stylesheet" type="text/css" href="ie.css" media="screen" />
   <![endif]-->
</head>
<body>
   <div class="clear">
      <div style="float: left;"></div>
      <div style="float: right;"></div>
   </div>
</body>
</html>

main.css

.clear:after {
   content: ".";
   display: block;
   height: 0;
   clear: both;
   visibility: hidden;
}

ie.css

.clear { zoom:1; }

Getting it working in IE/Mac

As described in the P.I.E article, an inline-block trigger on the wrapper will trigger Internet Explorer’s  built in auto-clearing. There are 2 ways to do this:

Overwriting display

Apply 100% width to the inline-block in your main stylesheet This works 99% of the time, just be aware of issues with the IE box model bug.

Add this code to main.css after the clear:after rule:

.clear { display:inline-block; width:100%; }

You now need to revert the display property back to block for IE/Win to get the auto-clearing effect to work. Replace the code in ie.css with:

.clear { zoom:1; display:block; }

Browser sniffers

Have different stylesheets for IE/Win and IE/Mac and include them using a server-side or JavaScript browser sniffer. This is arguably the cleanest fix.

First off remove the conditional include from MyPage.html (<!–[if IE]> …). This file will be included later on using a different method.

Create a new file called iemac.css:

.clear { display:inline-block; width:100%; }

PHP users can them add this code in the html <head> element:

<?php
$browser = strtolower($_SERVER['HTTP_USER_AGENT']);
if (strpos($browser, 'msie')) {
   if (strpos($browser, 'mac')) {
      echo "<link rel='stylesheet' type='text/css' href='iemac.css' />";
   }
   echo "<link rel='stylesheet' type='text/css' href='ie.css' />";
}
?>

Alternatively, you can apply a fix using JavaScript. Again this goes in the <head>:

<script language="javascript" type="text/javascript">
<!--
if (navigator.appName.indexOf("Microsoft Internet Explorer") >= 0) {
   if (navigator.platform.indexOf("Mac") >= 0) {
      document.write("<link rel='stylesheet' type='text/css' href='iemac.css' />");
   }
   document.write("<link rel='stylesheet' type='text/css' href='ie.css' />");
}
// -->
</script>

Tags: , ,

29th December 2008

font-sizes-29dec081A quick note to developers that are styling elements that use monospace fonts (pre, code, q, etc). Be aware that some browsers, like Safari and Chrome, have their own fixed-width font size preference, which by default is set to 13px. This upsets proceedings when you apply a proportional (% or em) font-size to the body.

There are three solutions to counter this problem:

  1. Apply font-size to each element separately
  2. Remove monospace from the font stack and treat it as a variable spaced font
  3. Use a fixed font size

Firefox and Internet Explorer have a single default font size so you can’t apply a larger size to monospace elements.

On the same subject, Google Chrome users can also set different default sizes for their serif and sans-serif fonts. By default these are identical so it will not affect the styling for the majority of users.

Tags: , , , , ,

26th August 2008

IE6 is broken.


#menu ul.level2 li {
display: block;
}

#menu ul.level2 li a {
display: block;
float: none;
border: 1px solid transparent; /* Stops the box from jittering on hover */
margin: 0.25em 0px;
padding: 0.3em 0.6em;
background: transparent;
color: #666666;
font-weight: normal;
}

#menu ul.level2 li a:hover {
background: #f36e45 url(../images/menu-level2-bg-hover.gif) left top repeat-x;
color: #ffffff;
border: 1px solid #f2683d;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
}

2 major problems. There is a large margin on the bottom of my list items, and there is a funny dark grey border around each list item. So why these 2 bugs?

Grey Border

The grey border is caused by IE6′s failiure to render transparent borders. It instead falls back to the color property (which in this case is set to #666666).

This is the first place on my site where I need to render something differently in IE6 to other browsers. There are 2 ways of doing this:

  1. Use the famous ‘* html’ hack. IE has a mysterious wrapper around the html tag (god only knows why!).
  2. Include another stylesheet for IE6

For a site of this size, the sensible option was to include a separate stylesheet for IE and below. The stylesheet should only render in IE5 and 6 because of the @import hack (hides the stylesheet from all v4 browsers):


<!--[if lt IE 7]>

<mce:style type="text/css" media="screen"><!  @import "style/ie6.css"; -->

<!--[endif]-->

To fix the border, we set the border color to a color we’ll never use within the element or on any of it’s children – pink is usually a good bet. We then apply the Microsoft CSS filter property to that color to make it transparent.


#menu ul.level2 li a {
border-color: pink;
filter: chroma(color = pink);
}

Tags: , ,

Page 1 of 212