Really simple drop shadow

by David Alfaro 10. October 2008 11:14

What are we facing?

I want the simplest solution to have a drop shadow effect on an image using just CSS. What is the shortest piece of code for drop shadow?

The Solution

The shortest piece of code for making a drop shadow is found in the book CSS Mastery of Andy Budd et al.

The shadow is a constructed via an outer "div" element wrapping the image. For example:

<div class="img-wrapper"><img src="tiny-logo.gif" alt="Aggiorno" /></div>

The tiniest CSS code you need to do drop shadow is:

.img-wrapper {
       background: url("shadow.png") no-repeat bottom right;
       clear: right;
       float: left;
.img-wrapper img { margin: -8px 8px 8px -8px; }

Displaying the pretty drop shadow you wanted:

Aggiorno

 

 

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

seo | css

Using just one background image to rollover images in links

by David Alfaro 10. October 2008 08:15

What are we facing?

I liked the post about Rollover Image for links using pure CSS but I would like to have just one image, not two: one for the "regular state" and another for the "hover state". There could be a delay between loading the first image and the second image, causing flickering. Is it possible doing that with just pure CSS? Am I being too demanding?

The Solution

Fortunately, CSS provides the power to do that. It is called the Pixy-style rollover. Let's use the same example of the previous post.

Here is the same image but merged vertically:

Aggiorno image

Using the following link code:

<a href="http://www.aggiorno.com/try.aspx" id="pixy"><span>aggiorno</span></a>

And using the following CSS

  a#pixy {
       background:transparent url(“Aggiorno-sprite.jpg”) no-repeat scroll center top;
       display:block;
       height:110px !important; 
       width:110px;
  }
  a#pixy span { display:none; }
  a#pixy:hover { background-position:center bottom; }

You then will get the link showing the top part of the image when regular state. In hover state, the bottom part is displayed. Hover it and believe your eyes:

aggiorno

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

seo | css | standards

Rollover Image for links using pure CSS

by David Alfaro 10. October 2008 02:18

What are we facing?

I want to achieve a button like effect for some of my links. For instance, it's a matter of positiong the "Download" link more prominent and catchy. I want that link to behave like a button when I hover it. Another option is to have a clickable image with change a little bit when hovering. Of course, I want that effect made entirely in CSS. Is it possible?

The solution

Yes, there is a way, let's based the following example of rollover with images on the Stuart Robertson's post about it.

Choose a image for the regular state of the link (no hovering state):

Just for simplicity, do a silly change to that image to produce a rollover image

Build the link wiht a "span" element with a meaningful description inside. Never forget those image based browsers.

<a href="http://www.aggiorno.com/try.aspx" id="rollover"><span>aggiorno</span></a>

We are almost there. Now the following style for achieving the rollover effect:

  a#rollover { background-image:url("Aggiorno-regular.jpg"); 
               height: 110px; width:110px; display:block; }
  a#rollover span { display:none; }
  a#rollover:hover { background-image:url("Aggiorno-rollover.jpg"); }

This style set background image for the regular state of the link, hides the span content and shows the rollover image when hovering. Our baby now looks like (hover it):

aggiorno

Some external references

Currently rated 4.0 by 2 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

seo | css | standards

Pure CSS tooltips

by David Alfaro 9. October 2008 08:35

What are we facing

I want to provide my links with tooltips, those little boxes that pop up when users hover the mouse over the links. How do I implement tooltips with pure CSS?

The Solution

The trick is made by inserting the text for the tooltip in a "span" element inside the "a" element. Then, use some CSS to hide it and to show it as a pop up when you hover. The good thing about this technique is that the tooltip text is inside the HTML markup, hence is visible to web crawlers. Let's see some examples.

A pretty good CSS code can be found in Pure CSS Tooltips, which gives the following style

a.info{
     position:relative; /*this is the key*/
     z-index:24; background-color:#ccc;
     color:#000;
     text-decoration:none} 
a.info:hover{z-index:25; background-color:#ff0} 
a.info span{display: none} 
a.info:hover span{ /*the span will display just on :hover state*/
     display:block;
     position:absolute;
     top:2em; left:2em; width:15em;
     border:1px solid #0cf;
     background-color:#cff; color:#000;
     text-align: center}

Let's see how it looks (hover the mouse over the links):


If you want a simpler way to do it, Kollermedia.at provides a shorter code

a.info2 span
  {
      display: none;
      padding: 2px 3px;
      margin-left: 8px;
      width: 130px;
  }
  a.info2:hover span
  {
      display: inline;
      position: absolute;
      background: #ffffff;
      border: 1px solid #cccccc;
      color: #6c6c6c;
  }

Let's see how it looks (again, hover the mouse over the links):

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

css | standards | seo

Navigation bar using list elements instead of table elements

by David Alfaro 6. October 2008 10:04

What are we facing?

You want a navigation bar that degrades gracefully on text based browsers. You will also want to have a navigation bar constructed with the correct elements to express the closest semantics to a “Navigation Bar”.

The Solution

The most currently recommended way to express Navigation Bars is using list elements. Semantically, navigation bars are simple lists of links to interest points of the site, that is, is just one dimension, it doesn’t justify the use of table elements. Tables are meant for data tabulation. Besides, tables are not friendly with text based browsers.

If you take a look at the source of this site’s Navigation Bar you will see something like:

          <ul>
                 <li><a href="http://www.aggiorno.com/default.aspx">home</a></li>
                 <li><a href="http://www.aggiorno.com/about-aggiorno.aspx">products</a></li>
                 <li><a href="http://www.aggiorno.com/try.aspx">download</a></li>
                 <li><a href="http://www.aggiorno.com/learn.aspx">aggiornings</a></li>
                 <li><a class="redlink" href="http://www.aggiorno.com/blog">blog</a></li>
                 <li><a href="http://www.aggiorno.com/contact.aspx">contact</a></li>
          </ul>

Using CSS magic, you can disable bullets, reveal content for browsers supporting CSS and hide content for those text based browsers.

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

css | seo | idea | accessibility

Get accessible pages by replacing text with Background-Image

by David Alfaro 6. October 2008 02:35

What are we facing?

More often than not, you come up with a beautiful title design based on a font inspired by Dali's most wildest dream. Out of the blue, somebody tells you that you can't go ahead because that font may exist only in your computer, and of course in the hypothetical Dali's computer. Your mom didn't raise a fool, so you just convert the title to image, and now everybody can see it. Think twice, text based browsers (blind users do use them) can't. No problem, just add an alternate text. Not so fast, for search engines “hx” (header) and “title” elements have more SEO relevance than “alt” (alternate text) attributes, it’s just about semantic best practices.  There must be a way to let your artistic spirit be expressed, life can't be that bad.

The Solution

Wait a minute. Is not the header (just above) in font Shelley Allegro? Yes, it is. The immense majority of the computers don't have it, so I did an image of it. But if you see this post using a text based browser like Lynx, or Firefox Accessibility Extension, you will be able to see "The Solution" in plain text. It is “h2” header element. How come? Take a look at the source code.

You will  see this:

<h2 class="firh2">
	<span class="firspan">The Solution</span>
</h2>

Let's introduce the Fahrner Image Replacement method. In this post you will see the basics of that clever method. By having the text of the “h2” inside a “span” element, you can play with styles a little bit. For those having styles and images, the following  CSS will show the image we want:

 .firh2
 {
       background-image: url( "fir-the-solution.gif" );    
background-repeat: no-repeat;    
height: 31px; } .firspan
{
      display:none; }       

The "firh2" id will set image I want as the background of the header, without repetition of it and with the actual size of the image to avoid stretching. The “firspan” will hide the the text of “span”.

For those text based browsers, neither styles nor images are loaded, so the “span” content is displayed. 

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

accessibility | css | idea | seo

How to prevent Google from indexing some pages of my site?

by David Alfaro 3. October 2008 03:00

What are we facing?

There are circumstances when I want to tell Googlebot to ignore some URLs of my site. For instance, Google lists the cases when Googlebot may unnecessarily consumes excessive broadband:

  • Additive filtering of a set of items.
  • Dynamic generation of documents.
  • Problematic parameters in the URL.
  • Sorting parameters.
  • Irrelevant parameters in the URL, such as referral parameters.
  • Calendar issues.
  • Broken relative links.
How do it prevent Google from indexing those URLs?

The Solution

Besides best practices to avoid those behaviors, you can make use of the robots.txt file in the root of your site. The Wikipedia explains that such file must follow the Robots Exclusion Protocol which" is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a website which is otherwise publicly viewable".

The next is an example that tells all crawlers not to enter four directories of a website:

 User-agent: *
 Disallow: /cgi-bin/
 Disallow: /images/
 Disallow: /tmp/
 Disallow: /private   

Another alternative is using the META tag for telling the robots not to index any specific page, like this:

  <html>
  <head>
  <title>...</title>
  <META NAME="ROBOTS" CONTENT="NOINDEX">
  </head>

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

seo

Rewrite engine for URLs and SEO

by David Alfaro 2. October 2008 11:11

What are we facing?

Rating higher for SEO is also achieved by having a simple URL structure. Any URL should be intelligible for humans, if you accomplish so, you will make it really understandable to Googlebot. Complex URL by using multiple parameters may cause an abuse of broadband by crawlers. How can I have simpler URL structures?

Solution

You have to rewrite the URL at server level and to use Regular Expressions to identify the original URL structure and to construct the desired one. In the case of Apache server, you will need the mod_rewrite module installed. In other side of the street, IIS 7.0 supports rewriting by HttpModules. Take a look at

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

seo

About Aggiorno KC

Aggiorno RSS Feeds As Web developers, we are always hunting for pieces of wisdom spread all over the Web, by friends, by books, or both. Normally it requires time and effort to search and locate that wisdom and then even more to implement it. Knowledge Capsules provide you with a consolidated place to find all the specific pieces of code and advice you are commonly looking for, all provided by fellow Web developers.

IE8 Compatibility Wizard

Automatically upgrades your website to render correctly in IE8!

Internet Explorer 8 Compatibility Wizard

Get it today!


ArtinSoft Corporation ArtinSoft is Microsoft Certified Partner ISV/Software Solutions and Microsft Visual Studio Partner

With over fifteen years of experience, ArtinSoft has proven to be a key player in software evolution, by allowing customers from all over the world to ensure business continuity and compliance through software migration solutions and developer tools created upon principles of artificial intelligence. At present time, ArtinSoft Corporation remains a private firm in constant growth through a strategic partner network. Read More...