20070124 Wednesday January 24, 2007

MOVING!

This page has officially been migrated to csskarma.com. please update your bookmarks. a new RSS feed will be active shortly as well

visit: http://www.csskarma.com

_tim
Posted by tcwrigh2 ( Jan 24 2007, 05:20:38 PM EST ) Permalink Comments [0]
20061214 Thursday December 14, 2006

Web2.0 Background with pure CSS

With everyone throwing around the term "web2.0" and try out new things, I thought I'd give it a try and see if some CSS can create a web2.0 look for a website (gradients, glassy buttons, etc.). I also love irritating graphic designers by finding a CSS alternative to using bulky images. So I sat down to see what I could come up with; this is what I got:



LINK TO IMAGE (if it's not showing up)

That split-color background is a fairly common sleek trend in the age of web2.0

examples:

you get the point.

if you examine the graphic, it's basically 2 flat colors, a few hex codes apart. I consistently see people using graphics to achieve this effect, but now you don't have to!

The code is below, you can copy it and customize it as you wish. I'll just explain some of it now. The HTML is nothing special, just your basic unordered list, so I'll skip that.

The main CSS components that make this work are in"#nav" and "#nav a".


#nav:

border-top:12px solid #FCDB58 creates the top half (lighter yellow)
background: #FC0 creates the bottom half (darker yellow)
border-bottom:4px solid #F60 is just the orange bottom border
position:relative makes this work in different browsers

#nav a:

margin-top: -7px pulls the text over the top border making it look like the div is split in half
position:relative makes this work in different browsers (it's important to have both)
everything else is pretty standard for horizontal navigation. Feel free to email me with any trouble.

cheers,
_tim


CSS:

#nav{
    height:12px;
    background: #FC0;
    border-top:12px solid #FCDB58;
    border-bottom:4px solid #F60;
    padding:0;
    clear:both;
    position:relative;
}


#nav a{
    color:#26354A;
    padding:0 10px;
    display:block;
    font-size:70%;
    border-right:solid 1px #F60;
    margin-top: -7px;
    position:relative;
}

#nav ul{
    list-style:none;
    margin: 0px;
    padding: 0px 0px 0px 20px;  
    font-size:100%;
}

#nav li{float:left;}


Verified in:

- Firefox 2.0 (PC)
- Firefox 2.0 (MAC)
- Internet Explorer 6
- Internet Explorer 7
- Opera 9
- Safari 2.0

Posted by tcwrigh2 ( Dec 14 2006, 12:58:11 PM EST ) Permalink Comments [1]
20061204 Monday December 04, 2006

Web Developers: Taking Action

This is a call to arms for all the web developers out there who constantly complain about Microsoft and how they didn't auto update when IE7 was released.

All over the web I see developers complaining about how they have to develop for IE 5, IE6 & IE7, but there are no real solutions presented, just a lot of talk about how bad microsoft is. I'm asking web developers to make steps to make the average user aware that there is an updated version of internet explorer out there.

People use IE. Microsoft is everywhere, and the average user is not going to switch to firefox. I think helping people move onto IE7 and start abandoning IE6 is a step in the right direction. So here's my solution

developers: start letting your users know about their old browser with this code:

HTML:
<!--[if lte IE 6]>
    <div id="browser">You are currently running an old version of Internet Explorer <a href="http://www.microsoft.com/windows/ie/default.mspx" target="_blank">click here to update your browser</a></div>
<![endif]-->

CSS:

#browser{
    display:block;
    background:#AA030D;
    color:#FFF;
    font-weight:bold;
    text-align:center;
    font-size:100%;
    line-height:2em;
}
#browser a{
    color:#FFF;
    text-decoration:underline;
}
#browser a:hover{text-decoration:none;}

Customize as you wish. If someone comes to your site using IE6 or less it will let them know and provide them a way to update to IE7. I installed it on this site if you want to see it in action (open in IE6-ish).

I hope this idea spreads, I'm not supporting IE by doing this. I just want to take some steps towards people using updated broswers (yea, yea i know). Let's stop complaining and do something about it!

cheers
_tim


Posted by tcwrigh2 ( Dec 04 2006, 04:26:44 PM EST ) Permalink Comments [1]
20061116 Thursday November 16, 2006

IE 7 Base Tag Issues

This is just a quick post because I noticed a fair amount of people have been asking about a problem in IE7 with how a base tag acts.
Previously in Internet Explorer you could put a base tag anywhere on a page and it would work fine. Now you have to put it in the <head> tag, and you can only use one per page.

the public outcry: "what the hell? why'd they do that?"
the karma answer: "it's small step microsoft took towards being more standards compliant, let's embrace it."

This may be a huge pain for a lot of developers because it probably broke a lot of things (images, links, etc.) but I assure you, it's a good thing and they're heading in the right direction. So, right after </title> use:
<base href="http://www.yourwebsite.com"> <'/base> (take out the apostrophe)

also, i don't think its a self closing tag anymore so you need the </base> at the end.

Here's a full description of the new IE base tag policy: http://blogs.msdn.com/ie/archive/2005/08/29/457667.aspx

cheers,
_tim
Posted by tcwrigh2 ( Nov 16 2006, 03:53:23 PM EST ) Permalink Comments [0]
20061115 Wednesday November 15, 2006

Dummy Scrollbar: The Firefox Wiggle

This is a method I came up with some time ago to remove, what I call, the Firefox Wiggle. Let me explain...

When viewing a small (height-wise) webpage Internet Explorer will insert a faded out (inactive) scrollbar that takes up...let's say, around 40 pixels or so and when you navigate to a longer page the scrollbar becomes active, still taking up around 40 pixels. It's a good thing; this keeps a center aligned website centered as you move from short pages to long ones.

The problem lies in Firefox (insert a web developer gasp here). Putting Firefox in the same sitution described above, trouble ocurrs.
FF doesn't insert a dummy scrollbar so when a vertical scroll is needed the page shifts 40 pixels (ish) to the left to accomodate space for the scrollbar, which is extremely irritating.

This is how you insert a dummy scrollbar in Firefox via CSS, it's pretty simple. There are 2 ways...
Method 1:
html {overflow-y:scroll;}

Method 2:
html {min-height: 100%; margin-bottom: 1px;}

Of course there are positives and negatives in each method.
Method 1 will create the dummy scrollbar exactly as IE does, works great. However, "overflow-y" is not valid CSS markup. So, if you care about having valid markup, this isn't the answer. Otherwise, it's outstanding.

Method 2 is perfectly valid CSS, but, as you can see by looking at it, it creates an active scrollbar by inserting 1px of margin to the bottom of the page. This means your page will have atleast 1px of scroll at all times. This is the method I use now mainly because it validates. But they both work pretty well.

See it in action:
No forced scrollbar: Alpha Road
Look at this page in IE and FF to see what I mean by the dummy scrollbar IE inserts and FF omits

Forced Scrollbar: DELTA
You can see here what happens when using method 2

I hope that helps some

cheers,
_tim
Posted by tcwrigh2 ( Nov 15 2006, 04:41:39 PM EST ) Permalink Comments [1]
20061108 Wednesday November 08, 2006

Searchbox Background Image

This is a neat thing i saw in google's custom search box, and I've seen it other places, but for whatever reason I decide to see how it really works. So I download google's JS file and started hacking away. Below is what I came out with, slightly modified so it's easier to read through.

It's pretty basic stuff, but I like the effect it gives and it allows more freedom in designing a go button without having to put the word "search" in it. The onblur effect is nice, it replaces the background image if you move off the searchbox while it's empty. Anyways, enjoy !

cheers,
_tim

This searchbox is located at delta.ncsu.edu to see it in action.


HTML:

<form name="search" method="get" action="http://www.google.com/search" id="search">
    <label for="q">search delta:
    <input type="text" id="q" name="q" />
    <input type="hidden" value="www.yourwebsite.com" name="as_sitesearch" />
    <a href="javascript:document.search.submit()"><img src="images/go.jpg" alt="search this site"</a>
</form>
<script type="text/javascript" src="js/search.js"></script>

CSS:

#q{
border:solid 1px #7F9DB9;
width:112px;
color:#000;
height:auto;
font-size:90%;
}

JavaScript:

(function() { 
var f = document.getElementById('search'); if (f && f.q) {
var q = f.q;
var n = navigator;
var l = location;
if (n.platform == 'Win32') {}
var b = function() {
if (q.value == '') { q.style.background = '#FFF url(images/bg_search.gif) center no-repeat'; } };
var f = function() { q.style.background = '#FFF'; }; q.onfocus = f; q.onblur = b; if (!/[&?]q=[^&]/.test(l.search)) { b(); } } })();

Posted by tcwrigh2 ( Nov 08 2006, 11:00:52 AM EST ) Permalink Comments [0]
20061107 Tuesday November 07, 2006

Custom CSS Bullet Vertical Alignment

This is a problem I struggled with for a while. I like using non-traditional bullets, but if they're 1px too large, they won't line up correctly with the list item. So here's my solution: background image on the list item, I really find it hard to believe that it didn't occur to me earlier while I was fighting margin and padding to align the stupid bullet with the text. Anyways, just in case, anyone else had this problem I thought I'd post what I found. I just used some dummy text in the lists.

Unstyled 

  • Do not put anything but LI list items inside an UL. 
  • The COMPACT attribute is not widely implemented. 
  • Not all browsers support the TYPE attribute

Styled with " list-style: disc url(img); " [this is the problem] 

  • Do not put anything but LI list items inside an UL.
  • The COMPACT attribute is not widely implemented. 
  • Not all browsers support the TYPE attribute
.disc li{
    list-style: disc url('bullet_arrow_large.gif');
    padding-top: 3px;
    padding-bottom: 3px;
}

Styled with " background: url(img) no-repeat left center; " [this is the solution] 

  • Do not put anything but LI list items inside an UL. 
  • The COMPACT attribute is not widely implemented. 
  • Not all browsers support the TYPE attribute

.bg-img li{
    list-style: none;
    line-height: 34px; 
    background: transparent url('bullet_arrow_large.gif') no-repeat left center; 
    padding: 0px 0px 0px 25px;


Looks 100% better doesn't it? AND it's perfectly accessible since it's still a <ul>. You'll probably have to tweak the padding and margin according to the left-right position you want, but this should give you a good starting place.

cheers,
_tim

Posted by tcwrigh2 ( Nov 07 2006, 03:17:18 PM EST ) Permalink Comments [0]
20061103 Friday November 03, 2006

Web Development Link Library

Just a quick heads up that I finally filled out the link library section (above) and the about page. we'll hopefully be changing servers soon, so keep an eye open.

I guess while i'm here I can post some links:
I should probably add some of these to the link library...


Posted by tcwrigh2 ( Nov 03 2006, 11:41:15 AM EST ) Permalink Comments [1]
20061027 Friday October 27, 2006

Random CSS Background Image

I'm flirting with some dangerous downtime right now so I figure I'll write out a blog, maybe with something useful. Here goes nothing...

Link: http://www.javascriptkit.com/script/cut176.shtml

so that's the link I came across while searching for a random background image generator. It takes a little tweaking, but works really well with your style sheet and is pretty light-weight. If you're concerned at all about users browsing with JavaScript turned off you can also define a background image in the CSS file so that will load first and then the random JS image will load (you can see it happen if you rapidly refresh the page a few times, otherwise it's fairly smooth).

I've used this a few times with very little trouble, seems to work fine cross-browser, but again, if it doesn't for some reason, you'll always have the original bg image in the CSS to mask it.

Get FireFox

Cheers,
_Tim

Posted by tcwrigh2 ( Oct 27 2006, 09:58:29 AM EDT ) Permalink Comments [0]
20060919 Tuesday September 19, 2006

Base Tag & The Named Anchor

I recently ran into an accessibility problem while developing a very large site. To make development easier I used a <base> tag, but what I hadn't planned for (now that I was about 280 pages into development) was the "skip to content" anchor that is needed on every page.

After much cursing, I sat down to hack out a solution. Implementing the anchor link globally wasn't a problem (I just put it in the header include and had the anchor link jump to a div ID, rather than an physical link). This solution technically worked fine, this is where the <base> tag trouble comes into play. I 'Googled' for about 3 hours to find out that this is a fairly common problem, but there aren?t many large-scale fixes out there for it. So I sat down with a co-worker and we came up with this stuff:

Just to clarify:
With the <base> tag, we'll call it: http://www.<root>.com/, is in the header of every page; a normal anchor link "#content" will load up the page http://www.root.com/#content....every time. This is a problem on all pages, other than the index (and there are A LOT), because we can't have people clicking on an anchor and getting sent back to the homepage.

SOLUTION 1:
This is for a static HTML page...
base tag: <base href="http://www.<root>.com/"></base>
current page: http://www.<root>.com/contactus.html
anchor link: <a href="contactus.html#content">skip to content</a>

Your anchor links should work just fine, and you can still use the <base> tag. This is a good solution (IMO) for a reasonably size site.
If you have a large PHP driven site here is the solution we came up with:

SOLUTION 2:
base tag:
<base href="http://www.<root>.com/"></base>
current page: http://www.<root>.com/contactus.php
php in header include:
<?php
    $replaceTxt = 'http://www.<root>.com';
    $anchorUrl = str_replace($replaceTxt,'',$_SERVER['SCRIPT_FILENAME']);
?>
anchor link: <a href="<?php echo $anchorUrl; ?>#content">skip to content</a>

again, I made the anchor jump to: <div id="content"> because I already had it in every page, you can also use a regular named anchor.

That's it, pretty straight forward and it works great! DON'T FEAR THE BASE TAG!

cheers,
Tim

Posted by tcwrigh2 ( Sep 19 2006, 10:18:01 AM EDT ) Permalink
20060830 Wednesday August 30, 2006

CSS Wildcard - Solving Cross-browser Problems

Many of the problems I've noticed people having while developing a web site is browser compatibility issues between IE 6/7, FireFox, Opera and Safari. And since IE7 removed some of the old hacks we used (the !important tag and the box hack), it's become even more frustrating.

For starters, now we need to make a special CSS file for Internet Explorer, we do this by using an 'if statement' in the HTML. And that looks like this:


<link href="file.css" rel="stylesheet" type="text/css" media="screen" />

<!--[if IE]>
     <link rel="stylesheet" href="file-IE.css" type="text/css" media="all" />
<![endif]-->


What happens is, IE will run through the normal style sheet, apply those styles and then look through the IE style sheet and use any elements listed in there to override styles previously defined in 'file.css'; so it's not like you have to have 2 versions of the CSS file, only the values that need to be changed for IE.


That being said, I've been using this method for a while now and noticed that the IE style sheet can get quite large. So I took a step back and tried to think of an easier way to solve the browser compatibility problems. I then ran into the CSS wildcard character. The wildcard will override all values (and browser defaults) defined within it, this is what it looks like, and it should be located at the very top of your CSS file:


* {
       margin: 0px;
       padding: 0px;
       border: 0px;
       font-family: Verdana;
       font-weight: normal;
       font-style: normal;
       text-decoration: none;
}


It will remove all default margin, padding, borders, bolding (anything you want to define) from ALL elements. These can all be redefined later in the CSS file like this (for example):



h1,h2,h3,h4,h5,h6{font-weight:bold;}


This method will solve a lot of your browser compatibility problems and can cut the IE style sheet down to only a few elements. it's especially helpful when styling forms since there are a lot of default padding and margin values on forms and form elements that many don't think of often enough.I hope this helps, enjoy.
cheers,
tim

Posted by tcwrigh2 ( Aug 30 2006, 12:58:28 PM EDT ) Permalink Comments [2]
20060829 Tuesday August 29, 2006

CSS3 Preview

I found a preview of some of the new properties coming out in ver.3 of CSS; some are very cool, few are actually useful, and I think 2 or 3 work in IE7 (Beta 3).....so there's not too much to be used in it. There's a border-image feature built in that kind of works, pretty neat, I'm not sure how much it'll get used.

Most of the stuff probably won't get used, so I'll just sum up the one's I like the most.
  • multiple background images, this is an OUTstanding feature to have, it should cut down div tag use a lot. I can see it getting abused a bunch too though. This, however doesn't work in IE7 or FireFox 1.5.0.6...so again, probably low usage, but very cool.
  • text-shadow, exactly what it sounds like, no more need for image drop shadows on text. This, surprisingly, looks pretty good for a generated shadow, not as hard as the old one. It only works in WebKit right now, I imagine Safari will pick it up soon too.
  • text-overflow, this inserts an elipsis (...) in text if it reaches a certain defined point. This is GREAT for when you want to sample text and put a "more..." link at the end. Oddly enough, this is supported by IE6+ and not FireFox 1.5.0.6
  • background-size, conrtolling the size of a background image. this doesn't seem very usefull to me for things other than thumbnail images with a hover command, possibly zooming...but it's still pretty neat.
  • border-radius, this is BY FAR my favorite new feature, it allows you to set the curve radius of a border, so in theory you could put a circle border around something....BUT of course, no IE support, as of right now. I'm hoping this get put in IE7 before it gets released in the Fall, but I doubt it. This works in FireFox 1.5 if you want to play around with it.
So that's what I got for you today, it looks like a pretty well thought out upgrade to CSS, but of course it's all useless until browsers comply with the new standards.

For more CSS3 checkout: http://www.css3.info/preview/

-Tim


Posted by tcwrigh2 ( Aug 29 2006, 10:33:36 AM EDT ) Permalink
20060824 Thursday August 24, 2006

JavaScript Form Checker

I just came across this link that was sent to me about a month ago, it's very cool so I thought I'd share: Remember the Milk.

You don't have to sign up for anything, I'm posting it, basically, to show the form-checking. Up to now I've been using Dreamweaver?s form validator to check if my forms are complete. It's very easy, but doesn't t really add any *POP* to a page.

This is using a JavaScript function to check each form field to see if it?s complete and then producing a check or an 'X' accordingly. Lemme see if I can go a little deeper into that...
The JS file is here if you want to take a look at it

A quick way to get this effect would be to download the .js file, mimic the form, and then customize it accordingly. You?ll get a bunch of code you don't need, but it's a lot faster than hacking through the JavaScript.

They have a cache function called cacheDom that checks each form field if you're a repeat visitor, you might want to take that out, but otherwise, it's pretty clean script.

I really don't have anything of merit to say, just thought I'd share that link.

-Tim

ps. I have another post for dealing with browser compatibility in CSS (IE vs FF & Safari), but I'll save that for another day...suspenseful isn't it?

Posted by tcwrigh2 ( Aug 24 2006, 09:41:32 AM EDT ) Permalink
20060816 Wednesday August 16, 2006

CSS Resources

This is just a list of CSS resources I've used in the past, I give them the "Tim Seal of Approval" - in no special order
So, there's a few off the top of my head, they're all good resources. Some of them are code snippets, articles, small tutorials, etc. Of course, there's never a problem Google can't solve too.

Enjoy,
       Tim


Posted by tcwrigh2 ( Aug 16 2006, 09:46:35 AM EDT ) Permalink