Ajax and Ajax Frameworks

I have been a developer for nearly 20 years and a web developer for about 10 years. Over the years, I have considered creating a blog to share the things I have learned (and am learning) about web design and development, but I never seemed to have the time. When I began learning about web development using Ajax and Ajax Frameworks, I decided to take the time to create this blog.

My intention for this blog is to focus primarily on Ajax Frameworks, but since web development requires knowledge of many technologies, I will occasionally write about things such as CSS, Javascript, PHP, MySQL, Flash, etc.

Lately, I have been using JQuery as my primary Ajax tool. Although I have used other Ajax Frameworks in the past (Dojo Toolkit, Yahoo! User Interface Library, Scriptaculous/Prototype), JQuery has thus far been the easiest to learn. In my first few posts I will discuss some of the JQuery Plugins that I have created. Some of these include: a plugin for Google Maps (jquery.imGoogleMaps), Form validation and submission  (jquery.imValidateForm), Page Populater (jquery.imPagePopulate), and a plugin to create lists (jquery.imList).

While I am still learning about some of the other Ajax Frameworks, I hope that what I have learned will be helpful to others. Just remember, “When you can pull the pebbles from my hand…”

Share

CSS: inline-block IE7 Hack

Thursday, October 22nd, 2009

I was demoing a recent web design to a client when I noticed that the menu items were not displaying correctly. The client uses ie7. While Firefox is my primary browser, I usually test my design in IE and Safari (and tweak if necessary). I didn’t this time because I did not think there was a difference for the CSS styles that I was using. I was wrong.

I usually use li elements for menu items:

<ul>
	<li><a>Home</a></li>
	<li><a>About</a></li>
	<li><a>Contact</a></li>
</ul>

To create horizontal menu items, I change the display attribute to inline in my CSS file.

li {
    display:inline;
}

For this particular design, I added a vertical divider (image) between each menu item. In order to do this, I used the inline-block attribute.

#menu li {
	display:inline-block;
	margin:0;
	list-style:none;
	width:122px;
	height:45px;
	background-image:url(images/menu_divider.jpg);
	background-repeat:no-repeat;
	background-position:top left;
	text-align:center;
	padding:0;
}

This looks fine in Firefox and Safari, but IE7 (and IE6) only supports inline-block on elements with natural display: inline. See CSS Display declaration.

I found a hack. Adding zoom: 1 and *display: inline will make IE7 display the li’s as inline-block.

#menu li {
	display:inline-block;
	margin:0;
	list-style:none;
	width:122px;
	height:45px;
	background-image:url(images/menu_divider.jpg);
	background-repeat:no-repeat;
	background-position:top left;
	text-align:center;
	zoom: 1;
	*display:inline;
	padding:0;
}

Next time, I will remember to test my designs in the major browsers before it is shown to the client.

Share

42 Responses to “CSS: inline-block IE7 Hack”

  • nathan Says:

    That’s a great resolution for another ie f***-up.

    Many thanks!

    Nath

  • waleed Says:

    Cross-Browser Inline-Block::
    http://ledomoon.blogspot.com/2009/12/cross-browser-inline-block.html
    .-= waleed ´s last blog ..Cross-Browser Inline-Block =-.

  • Ann Says:

    Thank you, thank you, thank you!!!!

  • Prowebdesign Says:

    Yap, thanks a lot from Latvia too ;) Great solution! Worked like a charm! :)

  • Miguel Says:

    It works!

  • LockeVN Says:

    Thanks. It’ work like a charm.

  • Ben Edwards Says:

    Any reason you can’t float:left & display:block

  • Kaela Says:

    I actually did a double-take when I refreshed and it solved everything! I had a somewhat more complicated hack going on, this makes my life so much easier. Thanks for sharing!

  • BrowserBugs Says:

    Nice one, works like a charm regardless that it’s not compliant css with a W3C scan however we can’t have everything can we?

  • Ali Says:

    Thanks so much for posting this, it worked perfectly!

  • Jan Says:

    Many thanks from Amsterdam!

  • Dan Says:

    Thanks from Brazil then. You saved my life.

  • Andrey Says:

    Thanks a lot from St.Pete!

  • Crystal Says:

    This was majorly helpful! Thanks!

  • Gabiru Says:

    Thanks so much!
    Best Regards

  • Bill Graham Says:

    MANY thanks! Works like a charm in IE8 = Tools “incompatibility” mode too

  • Rashid Says:

    made my day!

  • always21 Says:

    Thanks. Thanks for the solution. ^_^

  • georg Says:

    coooool … thanks a lot

  • Vanilla Cowboy Says:

    I cannot tell you have awesome this tip is.
    THANK YOU!
    I was going mad!

  • HNK511 Says:

    great hack worked just fine!

  • Hangz Says:

    Thank You for this simple solution!
    It works great, and you saved for me a lot of work!

  • rychu Says:

    Omg, thank you a lot pal !! Greetings from Poland :)

  • HerbyDerby Says:

    *whew* Saved again!

  • Erik Says:

    Worked great, many thanks!

  • jbcarey Says:

    thank you very much!

  • 123 Says:

    thx a lot

  • ezhhhhh Says:

    Many Many thanx =)

  • Ehsan Says:

    Thanks …
    Very Good Solution ;)

  • JP Toto Says:

    Mucho thanks.

  • Shane Says:

    Great solution for CSS issue. Thanks.
    Shane´s last [type] ..MAMP MySQL Won’t Start? – How to Fix the MySQL Server Issue in MAMP

  • Mike Says:

    Beautiful.
    Thanks for the hack. Works like a charm.

  • Ahmad Alfy Says:

    Going to my favorites … Thanks a million!

  • fartarget82 Says:

    Thanks! I really needed this.

  • Billy Says:

    Unfortunately, this hack breaks the format in FF.

  • abderahmane Says:

  • Dock Says:

    Thanks. Even in IE9, this basic CSS property is not fixed, but your solution saved me some digging.

  • Edward Says:

    Thank you very much, really helpful :)

  • dougzilla Says:

    This is brilliant.
    Thanks a lot.

  • Ritesh Says:

    Thanks dude… awesome work….

  • kkk Says:

    That’s great, but how “zoom” works?

  • Kelly Says:

    Awesome hack. Well done!

CommentLuv badge