RSS Feed
Dec 3

IE Bug – making a 0px high div

Posted on Thursday, December 3, 2009 in code bits, life's like this

I found that when I was creating div’s with ‘clear:both’ of different heights (which I use for spacing in my design)

.clear {clear: both; height: 0px; line-height: 0px; width:100%;}
.clear5 {clear: both; height: 5px; line-height: 5px; width:100%;}
.clear10 {clear: both; height: 10px; line-height: 10px; width:100%;}
.clear20 {clear: both; height: 20px; line-height: 20px; width:100%;}

Basically spanky IE makes your empty div the same height as your line height – so to fix this you need to specify line height ‘0px’ etc etc.

Bad bad IE

Sep 8

Correct accessible image / text replacement

Posted on Tuesday, September 8, 2009 in code bits

Stolen from : csswizardry

7.3.2 Gilder/Levin Method

Really great method…

By far the most robust and accessible method to date is the Gilder/Levin method (no URL available). This method maintains its integrity with all combinations of images on/off and CSS on/off.

This method works by laying an empty <span> over the top of the parent element with the required image applied as a background to that <span>:

Markup:
<h1><a href="./" title="Return Home"><span></span>Home</a></h1>
CSS:
#header h1 a{
	display:block; /* Required */
	width:250px; /* Width of image in question */
	height:70px; /* Height of image in question */
	position:relative; /* Required */
}
#header h1 a span{
	position:absolute; /* Required */
	width:100%; /* Stretch full width of parent */
	height:100%; /* Stretch full height of parent */
	background:url(images/logo.gif) top left no-repeat; /* Image */
	cursor:pointer; /* Required for links to appear like links in IE */
}

…but has its drawbacks:

There is however a drawback to this method; the empty <span>. This is bearable though as the <span> will have no impact on the usability/accessibility on the page, and will only impact ever so slightly on semantics. Now users can always see an image or text regardless of whether they have CSS and/or images disabled.

Sep 3

Weird first list item indent IE 6/7 – fix!

Posted on Thursday, September 3, 2009 in code bits

For some reason – IE 6/7 has a bug *sometimes* of making the first item of a list indented *RANDOM*

so your list looks like this:

<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>

Which will end up looking something like this (yes I just dummied it to look like this – it’s not the actual error):

  • Item 1
  • Item 2
  • Item 3

To fix it:

ul{
min-height: 1%;
}

ta da!
:)

Jul 14

accessibile css styled headings h1/h2/h3’s and menu navigation

Posted on Tuesday, July 14, 2009 in code bits

This is for heading/navigation etc.  It allows you to style images so they degrade gracefully (if the image is broken etc – it will show the text)

Is accessible!

Can be used on h1/h2/h3 etc for headings with a div/span or with an ul/li/a tag for a menu/navigation – can combine lots of combinations

H1 example

<div id=”contentMain”>

<h1 class=”heading”>Heading</h1>

</div>

#content h1
{
display:block;
height: 0px;
padding-top:23px; (this is the height of the image)
overflow:hidden;
color: #444444;
}
#contentMain h1.heading
{
background:transparent url(~/url/to/the/image/heading.gif) no-repeat left top;
}

<ul id=”mainMenu”>
<li id=”home”><a href=”home.htm”>Home</a></li>
</ul>

Active Page
<ul id=”mainMenu”>
<li id=”home”><a href=”home.htm” class=”highlighted”>Home</a></li>
</ul>

#mainMenu
{
float: left;
list-style: none;
overflow: hidden;
padding-top: 40px;
text-decoration: none;
}

#mainMenu #home a
{
display:block;
height: 40px;
width: 100px;
background: url(~/url/to/the/image/Home_Off.png);
background-repeat: no-repeat;
}
#mainMenu #home a:hover, #mainMenu #home .highlighed (for when you roll over & on the active page)
{
display:block;
height: 40px;
width: 100px;
background: url(~/url/to/the/image/Home_Off.png);
background-repeat: no-repeat;
}

Jun 17

Center align site using CSS

Posted on Wednesday, June 17, 2009 in code bits

HTML bit

<body>
<div id="wrapper">
**Rest of site goes here**
</div>
</body>

CSS bit

body {
text-align: center;
}

#container {
margin: 0 auto;
width: ***px;
}