Posts Tagged ‘nablopomo’

That last post? Some of you may have noticed that it doesn’t work very well.

The styles applied to the button and the button’s parent element make a difference in how IE (and to a lesser extent Opera) handle the positioned elements.

My current line of attack is to use more jQuery to remove some styles from the button itself and apply them to the inserted span. For Opera, I’m looking at the SVG solution.

This time I may wait until I’ve finished testing before posting.


The contents of this post are a few years old now and I can’t recommend them as best practice.

Today I decided to try and build rounded corners on a button that would work in both CSS 3 compliant browsers (Gecko and WebKit based browsers, i.e. Firefox, Camino, Safari, Chrome, etc.) and also in IE and Opera.

The HTML

<input type="submit" value="Go" class="button-rounded"/>

Nice and clean.

The CSS

.button-rounded {
        border: 2px solid #fff;
        padding: 0 2px;
        background-color: #2e4c37;
        color: #fff;
        font-weight: bold;
        border-radius: 4px;
        -moz-border-radius: 4px;
        -webkit-border-radius: 4px;
}

This is enough to do the trick in the known good browsers and in any unknown CSS 3 compliant browsers. (This part of the CSS 3 spec, whilst still not finalised, is unlikely to change.)

More CSS

span.corners {position: relative;}
span.corners i {position: absolute; width: 4px; height: 4px; background: url(corners.png) no-repeat;}
span.corners i.tl {top: 0; left: 0; background-position: 0 0;}
span.corners ispan.corners ispan.corners i.tr {top: 0; right: 0;  background-position: -4px 0;}
.bl {bottom: 0; left: 0; background-position: 0 -4px;}
.br {bottom: 0; right: 0; background-position: -4px -4px;}

Yet more CSS for IE (use a conditional comment or your hack of choice)

span.corners i.tl, span.corners i.tr {top: 1px;}
span.corners i.bl, span.corners i.br {bottom: 1px;}

(There’s a one pixel difference betwen the way Opera and IE draw the button, hence the branched CSS. This may not always be the case, depending on the CSS styles you use for the border but with a 2px wide border with a 4px corner radius it was the case.)

[Update] It seems that IE8 differs from IE7 in this respect. I’ll revisit this article when IE8 leaves beta.

The graphic

, a bit small, here it is ×4 . That’s all four corners in one graphic, for use as CSS Sprites in the above CSS code.

But where are these elements that this extra CSS references? They get added by JavaScript, in this case using the jQuery library.

The JavaScript

if(($.browser.msie && $.browser.version == '7.0') || $.browser.opera) {
        $('.button-rounded').wrap('<span class="corners">>/span>');
        $('span.corners').append('<i class="tl"></i><i class="tr"></i><i class="bl"></i><i class="br"></i>');
};

Why <i>? Because it uses the least code. If you like you can use <span> instead.

Why browser sniff? Because we don’t want to write extra code into the page for browsers that don’t need it and it’s hard to include IE and Opera but exclude FF and Safari by other means.

Remember that any browser excluded from the JavaScript and incapable of using CSS 3 will get a button with square corners. We are not excluding anyone from functionality, nor from the general design – just from one small detail.

The result

So Firefox and Safari get rounded corners via CSS. IE7 and Opera get some extra code which positions graphics over the corners of the buttons.

Still to do

IE6 has some problems with using the right and bottom CSS properties. Hence for the moment I exclude it from the JavaScript. This is what I hope to resolve in part 2.

There’s also a potential future-proofing issue – when Opera and IE start supporting border-radius this code will position the graphics over the rounded corners, which may or may not work depending on how closely their rounded corners match the ones Gecko draws (the graphic was produced from a screen shot of the corners in Firefox).

Part 2, in a few days.


There are only a few things that [info]pink_weasel and I disagree on, but one of them is the concept of jumping the shark. Lettice believes that it is a binary event – a show can only jump the shark once; there’s a before and there’s an after. I believe that it is always possible to find a new and bigger shark to jump over.

This disagreement normally surfaces whilst we’re watching or discussing CSI: Miami.

Tonight’s episode. In fact the pre-titles sequence of tonight’s episode is a perfect example of my thesis.

I’m not going to put a spoiler cut for CSI: Miami, okay?

Horatio gunned down seven gangsters – several armed with automatic weapons, three in or on vehicles – armed only with a pistol without getting a scratch on him; in fact it was nine shots, seven kills. Now, considering that this show jumped the shark a long time ago (Lettice maintains that it jumped, before a single episode had aired, as soon as David Caruso was cast) was this not a new and bigger shark to jump? Will there be a scene next year where Horatio takes out a tank or a helicopter gunship with his trusty sidearm?

Very True Mood: (amused) amused
Tags:

A reminder that you can see where I work in the episode of Spooks that starts on BBC 1 in fifteen minutes.


Mike emails to tell me that Jack Weil and Arthur Andrews are deceased and that he is in joint first place in the Deadpool game.


I seem to have fallen off the NaBloPoMo wagon by failing to post over the weeked. Every day in November is hence out but I will try to make 30 posts in the month. This one makes it 19 in 17 days.


On Saturday [info]pink_weasel (on a post-Cliff high) and I met up with some folks in Guildford and had lunch in a restaurant on top of a multi-storey car park. It sounds odd and a bit grim but the Thai Terrace is fantastic and I really want to go back in the summer and sit outside.


I also got given a copy of Grand Theft Auto, not the latest one, the last one. I like mayhem. :evil:


Well, no surprises there then.
How spoilerphobic are you? )

At the time of writing it can still be seen at http://www.bbc.co.uk/pudsey/ontv/.

Sigh, still spoilerphobic? )

Tags:

13 hour day at work. Bad servers. Not much with the brain. So as far as a NaBloPoMo post goes this is a token effort and made of fail.

Very True Mood: (tired) tired
Tags:

Seen the pics from the new Star Trek film yet? Spoilers ahoy ‘cos here are the treknical ones…

Hands up who thinks that this ship looks like it should be an intermediate stage between the movie-era Enterprise and the Ambassador class? I can hear the fanboys screaming…

So this is the USS Kelvin, destroyed some time before the main timeframe of the movie. NCC-0514. Hmm, I want to see more. And, on the really pedantic level, how does this fit into the same registry scheme that includes the NCC-638 USS Grissom form ST III?

And has it really been four years since I updated my Star Trek ships web site? Ouch.


The BBC ran a story today about how spammers make money. They estimated that with a click through rate of just 0.00001% it could be possible to make up to $2 million a year.

At work we deal on click through rates of double digit percentages and yet somehow don’t make $200 billion a year. The downside of being all ethical and using an opt-in list. ;-)

Meanwhile I got this spam in my akismet cesspool:

Hi there!
My first post at this great blog!
I wanna show u my dayly updated blog: [adjective adjective verb noun]
Have a nice day!
BB!

P.S. if you don’t want to see this message please write me to [email] with subject “NO ADS” and URL of your forum

Thank you for cooperation!

Allowing for the fact that 1 in 100,000 people are stupid enough to buy drugs from a spammer, how many webmasters are stupid enoiugh to send a forum URL to a spammer?

Tags:

Spooks has gone all technobabble on us. Nanoparticles activated by microwaves?

But more importantly, tonight’s BBC 3 episode (so on BBC 1 next Monday) was substantially filmed in our offices! And tomorrow we’ll all be looking at the board room and trying to figure out how they filmed some shots (Ben, you know, the one with no personality, hiding behind a pillar) without removing a window and suspending the camera in mid air outside.


Last week I was introduced to Playfire – a social networking site for computer gamers. It got me wondering why there’s no equivalent for wargamers.

There’s BoardGameGeek but (a) the interface sucks and (b) its remit is so much wider than wargames. TMP and Frothers are fine places to come together and talk about games but that’s all. Where’s the site where I can catalogue the games I play and the miniatures I own and connect with other players?

A lot of the functionality that the knitters have on Ravelry would be great – a flexible but standardised way of listing “projects” – which minis, which paints, which TOE, WIP photos, etc.

Considering how geeky and techie a lot of wargamers are, why has no one created the site? Is it simply because the idea of social networking isn’t really our thing?

Someone will now pop up in the comments and tell me about a site that I should have known about all along.