Best Solution for Web

July 12, 2008

Create a Lightbox effect only with CSS - no javascript needed

Filed under: Uncategorized, CSS

Ref. emanueleferonato.com

You may call it Lightbox, or Greybox, or Thickbox, but it’s always the same effect.

When you are on a page, and click on a photo or trig some event, a Lightbox is an effect that fades the pagein the background to show you new content in the foreground.

I mean this effect

Lightbox

In the upper example, when clicking on a photo the site fades to black and shows the photo, in the lower one when clicking on "login" the site fades to white and shows the login form.

There are tons of Lightbox scripts in the web, each one with its unique features and limitations, but all require massive use of Javascript or the installation of javascript frameworks.

In some cases, there are "lightweight" versions with "only" 40KB of Javascript.

This example does not want to compete with those scripts, but if you are looking for a simple, 100% CSS, 0% javascript lightbox, this may help you.

Features of this Lightbox:

100% CSS as said
You can insert any content in it (some scripts out there only allow images)

That’s all. Did you need something more? Think wisely…

Let’s start with the CSS

CSS:
  1. .black_overlay{
  2.     display: none;
  3.     position: absolute;
  4.     top: 0%;
  5.     left: 0%;
  6.     width: 100%;
  7.     height: 100%;
  8.     background-color: black;
  9.     z-index:1001;
  10.     -moz-opacity: 0.8;
  11.     opacity:.80;
  12.     filter: alpha(opacity=80);
  13. }
  14.  
  15. .white_content {
  16.     display: none;
  17.     position: absolute;
  18.     top: 25%;
  19.     left: 25%;
  20.     width: 50%;
  21.     height: 50%;
  22.     padding: 16px;
  23.     border: 16px solid orange;
  24.     background-color: white;
  25.     z-index:1002;
  26.     overflow: auto;
  27. }

The black_overlay class is the layer that will make the web page seem to fade. It’s a black 80% opaque background as long and wide as the browser that will overlay the web page (look at the z-index) and at the moment is not shown (look at the display).

The white content class is the layer with the photo/login screen/whatever you want to appear in the Lightbox overlay. It’s a white layer to be placed over the black_overlay layer (look at the z-index, greater than the black_overlay one). The overflow allows you to have a scrollable content.

In the html file, put this line just before the tag

HTML:
  1. <div id="light" class="white_content">Hi, I am an happy lightbox</div><div id="fade" class="black_overlay"></div>

Now, trig the action you want to open the Lightbox and insert this code:

HTML:
  1. document.getElementById(’light’).style.display=’block’;document.getElementById(’fade’).style.display=’block’;

For example, in a link would be:

HTML:
  1. <a href = "javascript:void(0)" onclick = "document.getElementById(’light’).style.display=’block’;document.getElementById(’fade’).style.display=’block’">Click me</a>

Remember to include in the lightbox the code to close it, for example

HTML:
  1. <a href = "javascript:void(0)" onclick = "document.getElementById(’light’).style.display=’none’;document.getElementById(’fade’).style.display=’none’">Hide me</a>

A complete example page could be

HTML:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2.     <head>
  3.         <title>LIGHTBOX EXAMPLE</title>
  4.         <style>
  5.         .black_overlay{
  6.             display: none;
  7.             position: absolute;
  8.             top: 0%;
  9.             left: 0%;
  10.             width: 100%;
  11.             height: 100%;
  12.             background-color: black;
  13.             z-index:1001;
  14.             -moz-opacity: 0.8;
  15.             opacity:.80;
  16.             filter: alpha(opacity=80);
  17.         }
  18.         .white_content {
  19.             display: none;
  20.             position: absolute;
  21.             top: 25%;
  22.             left: 25%;
  23.             width: 50%;
  24.             height: 50%;
  25.             padding: 16px;
  26.             border: 16px solid orange;
  27.             background-color: white;
  28.             z-index:1002;
  29.             overflow: auto;
  30.         }
  31.     </style>
  32.     </head>
  33.     <body>
  34.         <p>This is the main content. To display a lightbox click <a href = "javascript:void(0)" onclick = "document.getElementById(’light’).style.display=’block’;document.getElementById(’fade’).style.display=’block’">here</a></p>
  35.         <div id="light" class="white_content">This is the lightbox content. <a href = "javascript:void(0)" onclick = "document.getElementById(’light’).style.display=’none’;document.getElementById(’fade’).style.display=’none’">Close</a></div>
  36.         <div id="fade" class="black_overlay"></div>
  37.     </body>
  38. </html>

That you can find up and running in this page.

In this example everything is static and preloaded, but you can easily add some php/ajax code to make it more dynamic while keeping the effect 100% CSS based.

Hope you will find it useful, should you use it in one of your works send me a comment and I’ll feature your site as example.

Step by step CSS float tutorial

Filed under: Uncategorized, CSS

Ref. maxdesign.com.au

Floatutorial takes you through the basics of floating elements such as images, drop caps, next and back buttons, image galleries, inline lists and multi-column layouts.

General info

Tutorial 1. Floating an image to the right

Float an image to the right of a block of text and apply a border to the image.

Tutorial 2. Floating an image and caption

Float an image and caption to the right of a block of text and apply borders using Descendant Selectors.

Tutorial 3. Floating a series of "clear: right" images

Float a series of images down the right side of the page, with content flowing beside them.

Tutorial 4. Floating an image thumbnail gallery

Float a series of thumbnail images and captions to achieve an image gallery.

Tutorial 5. Floating next and back buttons using lists

Float a simple list into rollover "back" and next "buttons".

Tutorial 6. Floating inline list items

Float a simple list, converting it into a horizontal navigation bar.

Tutorial 7. Floating a scaleable drop cap

Float a scaleable drop cap to the left, resize it and adjust line-heights to suit your needs.

Tutorial 8. Liquid two column layout

Float a left nav to achieve a two column layout with header and footer.

Tutorial 9. Liquid three column layout

Float left and right columns to achieve a three column layout with header and footer.

 

101 CSS Techniques Of All Time

Filed under: CSS

 

Ref. noupe.com

CSS Sprites

CSS sprites save HTTP requests by using CSS positioning to selectively display composite background images. To maximize accessibility and usability, CSS sprites are best used for icons or decorative effects.

CSS Sprites



CSS Rounded Corners

Rounded corners is one of the most popular and frequently requested CSS techniques. There lots of ways to create rounded corners with CSS, but they always require lots of complex HTML and CSS. Here are easy ways to achieve this effect.



Image Replacements Technique

Thierry Image Placement: Image Placement vs. Image Replacement (FIR)

This technique is mostly for headlines by using CSS to replace normal HTML text, with a background image in order to achieve a particular look.Several different image replacement methods have been proposed, each with their pros and cons.

when you need image replacement you can check the Gilder/Levin Method as described by Dave Shea or, if the replaced text is linked and CSS support for IE/Mac is required, the Gilder Levin Ryznar Jacoubsen IR method.

image replacement



Sliding Doors

Sliding Doors of CSS introduced a new technique for creating visually stunning interface elements with simple, text-based, semantic markup.Beautifully crafted, truly flexible interface components which expand and contract with the size of the text can be created if we use two separate background images.

sliding doors


Sliding Doors" Box– Rounded Corners for All- The goal of this technique was to create rounded-corner boxes with visual flare and the absolute minimal amount of semantically correct markup. While making sure they could resize while keeping their backgrounds intact.

sliding doors



Image Text Wrap Technique

How many times do you have an image floated left in a block of content, but want to keep that content from wrapping around your image?

This technique allows you to wrap around image text flow control to emulate magazine style page layouts.

Image Text Wrap



Equal Height Technique

One of the somewhat frustrating properties of CSS is the fact that elements only stretch vertically as far as they need to. So how can we make all columns appear to be the same height? Several techniques was introduced to solve this issue.

  • Faux Columns- The simple secret is to use a vertically tiled background image to create the illusion of colored columns.
  • Equal Height Columns - revisited- A method to make all columns appear to be the same height but without the need for faux column style background images.
  • Equal height boxes with CSS- The trick is to use the CSS properties display:table, display:table-row and display:table-cell to make containers (in this case div elements) behave like table cells. The basic XHTML structure looks like this:
        <div class="equal">    <div class="row">    <div class="one"></div>    <div class="two"></div>     <div class="three"></div>    </div>    </div>    

    Here is the CSS used to make this structure behave like a table:

         .equal {            display:table;    }    .row {            display:table-row;    }    .row div {            display:table-cell;    }    


Turning A List Into A Navigation bar

Why use a list? Because a navigation bar, or menu, is a list of links. The most semantic way of marking up a list of links is to use a list element. Using a list also has the benefit of providing structure even if CSS is disabled.



Making Headlines With CSS

Headers in Web pages–marked up with h1, h2, h3, h4, h5, or h6 elements–help the reader determine the purpose of sections in content. If your header is visually stimulating, the odds are better that the section will capture your reader’s eye.

heading


  • Heading Style Gallery- Want something a little more stylish for your content headings (h1,h2,…) than a different font or color? Try one of the heading styles listed here to spruce up your content.
  • Typography for Headlines- Improve the typography in your headlines by being more creative, give them more ‘pop’, that sort of thing.
  • Making Headlines With CSS- With a dash of design, we can utilize CSS to stylize those Web page headers to catch the reader’s eye and encourage them to read on.


CSS Shadows Techniques

A technique to build flexible CSS drop shadows that can be applied to arbitrary block elements that can expand as the content of the block changes shape.

  • CSS Drop Shadows-Build flexible CSS drop shadows that can be applied to arbitrary block elements that can expand as the content of the block changes shape.

    CSS Shadows


  • Fun with Drop Shadows- Most of the existing techniques use negative margins, while this one is a really simple version wich uses relative positioning.
  • Drop Shadows By Phil Baines- This set of tests are based on an article found on A List Apart’s technique, but with less CSS coding.
  • CSS Drop Shadows II: Fuzzy Shadows- Picking up where Part I left off, in Part II designer Sergio Villarreal takes his standards-compliant drop-shadow to the next level by producing warm and fuzzy shadows.

    CSS Shadows


  • An improved CSS shadow technique- A very robust and easy-to-use technique for applying snazzy looking shadows using only Web technology and a few little image elements prepared beforehand.


CSS Transparency

One of the trickiest things to control, in a CSS-driven design, is the transparency of the interaction between foreground and background content.Below is a list of the best examples of the differing transparency approaches possible with CSS.

  • Partial Opacity- Placing text over an image can sometimes make it difficult to read, but with Stu Nicholls’s methods the background for the text is made ‘opaque’ using various methods of opacity (including css3) and the black text is then quite readable.

    CSS Transparency


  • Cross-Browser Variable Opacity with PNG- How to overcome flaky browser support for PNG so you can take advantage of this graphic format’s lossless compression, alpha transparency, and variable opacity.
  • Two Techniques for CSS Transparency


Various Link Techniques

  • Showing Hyperlink Cues with CSS- The CSS Guy shows us how to get the little icons next to hyperlinks that signify if that link will take you offsite, open a popup, or link to a file (as opposed to another html page). Here’s how to do it in a way that’s supported in IE7, Firefox, and Safari.
  • The ways to style visited Links- CSS offers various possibilities to make links more usable and preserve text readability at the same time. We need to differentiate visited and unvisited links, but we must keep text scannable and readable.
  • Link Thumbnail- Shows users that are about to leave your site exactly where they’re going. When that curious mouse pointer hovers over a link pointing to somewhere outside of your site, the script displays a small image of the destination page.
  • Iconize Textlinks with CSS- If you’re looking for more icons to implement, Alex provides a nice start.


 

Block Hover Effect Links

block links



Style an A to Z Index

style-az-list



Typography Techniques

  • CSS StyleFun- How to achieve various effects using css, including typography (kerning, drop caps, big 1st letter), styled block-quotes, hover opacity… nice tutorial because it gives sample code/style sheets for each thing.
  • CSS Fonts, CSS Typography- Included are tutorials on how to size fonts with CSS, such as using CSS relative units, such as font size keywords, em, or % (percentage) units, along with cross-browser, cross-platform CSS font considerations.

Typography



CSS Pagination

Pagination is a mechanism which provides users with additional navigation options for browsing through single parts of the given article. Can be referred to by numbers, hints, arrows as well as “previous” and “next”-buttons.

  • CSS Pagination Links- Inspired by the pagination interface you see at the footer of Digg.com.
  • Pagination 101- Pagination 101, that will give you some clues as to what makes good pagination.
  • Some styles for your pagination- Styles for WP-Digg style pagination plugin, Digg Style pagination Class, the modular version, and the original programed bye strangerstudios.

CSS pagination



CSS Tabs

Tabs-based interfaces allow multiple documents to be contained within a single window and tabs can be used to navigate between them. Using CSS, information is loaded instantly with Ajax-based techniques. Some of the most interesting techniques we’ve found in the Web are listed below.

  • Glowing Tabs Menu- uses a background image that accentuates the outline of the tabs. And to jazz it up, the selected tab "glows", by using the "Sliding Doors" technique to shift the original background image upwards to reveal the glowing version of the tab design. An exquisite yet professional looking horizontal menu.
  • DOMTab- is a unobtrusive JavaScript CSS navigation tabs that turns a list of links connected to content sections into a tab interface.
  • Control.Tabs- Control.Tabs attaches creates a tabbed interface from an unordered list of links/anchors that point to any elements on your page that have an id attribute.
  • Tabifier- Automatically create an HTML tab interface using plug-and-play JavaScript.

CSS Tabs



CSS Pullquotes

Pull quotes are commonly used in print publications to draw emphasis to a particular quote or excerpt from a document. They are quite common in magazines and newspapers and are usually short extracts from the article.

  • Simple CSS Blockquotes and Pullquotes- Blogsolid shows us how to get some sweet blockquotes and saucy pullquotes?
  • Automatic pullquotes- Using JavaScript based technique to add pullquotes without having to duplicate text in the markup.
  • CSS Pull Quotes- In this tutorial you will place the pullquote text in the title attribute of a paragraph or page division, and use the :before pseudo element’s ability to generate content to display the pullquote on the page.

CSS Pull Quotes



CSS Blockquote

A blockquote is used when quoting text from another source, usually another blog or website. Blockquotes are intended to accommodate a larger amount of text, so as a rule of thumb, use blockquotes when you are quoting more than one or two sentences.

CSS Block Quotes



Star Rater Techniques

CSS Star Rating



CSS Image Pop-Up

  • Cool CSS Image Pop-up- This is an Pop-UP image effect that is similar to the ones you see using JavaScript on mouseover or on click but THIS ONE uses ONLY CSS!
  • CSS Popup Image Viewer- With the help of CSS’s ":hover" pseudo class, combined with relative and absolute positioning, the enlarged images are simply included on the page as normal HTML, "popping" up on demand.
  • Pop-up images on inline links- When you hover over the link the image is then given its correct size and it pops-up, in this case beneath the link, but you can place it anywhere you like relative to the link.
  • Hoverbox Image Gallery- A super light-weight (8kb) roll-over photo gallery that uses nothing but CSS. View Example.

CSS Image Pop-Up



CSS Sitemaps

CSS sitemaps



Horizontal and Vertical Centering

 

 

 

Powerful CSS-Techniques For Effective Coding

Filed under: CSS

Ref. smashingmagazine.com

Sometimes being a web-developer is just damn hard. Particularly coding is often responsible for slowing down our workflow, reducing the quality of our work and sleepless nights with pizza and coffee laying around the laptop. Reason: with a number of incompatibility issues and quite creative rendering engines it sometimes takes too much time to find a workaround for some problem without addressing browsers with quirky hacks. And that’s where ready-to-use solutions developed by other designers come in handy.

One year ago we’ve published the post with 53 CSS-Techniques You Couldn’t Live Without where we provided references to the most useful CSS-techniques which are often used in almost every project. Over the last year we’ve been observing what’s happening with the CSS-based web-development, and we collected most useful CSS-techniques we’ve stumbled upon — for us and for our readers.

In this post we present 50 new CSS-techniques, ideas and ready-to-use solutions for effective coding. You definitely know some of them, but definitely not all of them. Some technique is missing? Let us know in the comments to this post.

Thanks to all developers who contributed to the CSS-based design over the last year. The community appreciates it.

CSS-Techniques

1. Triadic Background Setting with CSS
The Silverback web site uses three background images to create the illusion of 3D with simple CSS. No documentation is provided, however the source code is quite intuitive. [via Wilson Miner]

CSS-Technique

2. Creative Use of PNG Transparency in Web Design
With proper PNG support in Internet Explorer 7, and some handy JavaScript and CSS tricks to account for older browsers, we can use PNG images to greatly enhance our design vocabulary.

CSS-Technique

3. CSS Server-Side Pre-Processor

CSS-Technique

4. Advanced CSS Menu

CSS-techniques - Advanced CSS Menu

5. CSS SiteMap

CSS-techniques - beTech » CSS SiteMap » Oct 3, 2007

6. Styling File Inputs with CSS and the DOM
File inputs (<input type=”file” />) are the bane of beautiful form design. No rendering engine provides the granular control over their presentation designers desire. This simple, three-part progressive enhancement provides the markup, CSS, and JavaScript to address the long-standing irritation.

CSS-Technique

7. A Savvy Approach to Copyright Messaging
Derek Powazek suggests adding a copyright message to a photo and use CSS to crop its view. This is supposed to accomplish the goal of adding robust copyright information without defacing your own work.

Screenshot

8. Particletree Category List

CSS-techniques - Particletree » Automatically Version Your CSS and JavaScript Files

9. Advanced CSS Menu Trick
What we want to do here, is instead of simply altering the state of the navigation item the user is currently rolling over, we want to alter the non navigation items as well.

Screenshot

10. CSS hover effect

CSS-techniques - CSS hover effect | Veerle's blog

11. Creating a table with dynamically highlighted columns like Crazy Egg’s pricing table

CSS-techniques - Creating a table with dynamically highlighted columns like Crazy Egg's pricing table

12. A Stripe of List Style Inspiration
A different type of list and navbar styling. As stripes.

CSS List Style

13. Rediscovering the Button Element

CSS-techniques - Particletree » Rediscovering the Button Element

14. Dynamic CSS With Variables
Geoffrey Grosenbach describes how you can integrate CSS variables in CSS coding — with Ruby on Rails.

Dynamic CSS

15. Hyperlink Cues with Favicons
I wanted to extend the concept of hyperlink cues a little. For links that point to external sites, what if, instead of showing a generic ‘external link’ icon, we showed that site’s favicon?

CSS-techniques - Drop Shadow CSS

16. A CSS styled table version 2

CSS-techniques - A CSS styled table version 2 | Veerle's blog

17. CSS Step Menu
A method of designing the so-called step-menus, which have some steps users have to go through in order to achieve some aim. This menu offers a varying amount of steps, dependent upon the type of user accessing the application.

Stepmenu

18. Creating bulletproof graphic link buttons with CSS | 456 Berea Street

CSS-techniques - Creating bulletproof graphic link buttons with CSS | 456 Berea Street

19. Iconize Textlinks with CSS
Links are fun, but sometimes we don’t know where they take us. With this little CSS technique a user can identify a link by its icon. The updated release of the technique.

Screenshot

20. Better Ordered Lists (Using Simple PHP and CSS)
Ordered lists are boring! Sure you can apply background images and do quite a bit of sprucing up to a regular ordered list, but you just don’t get enough control over the number itself.

Screenshot

21. Circular Menu with CSS
This article shows how a beautiful circular navigation menu is created. In Spanish with Source code and an example.

Circular Menu with CSS

22. CSS Dock Menu

CSS-techniques - CSS Dock Menu

23. Digg-like navigation bar using CSS
This tutorial explains how to design a digg-like navigation bar using a liquid design with rounded corners for links.

Screenshot

24. 13 Awesome Javascript CSS Menus
13 “fresh” JavaScript+CSS-based navigation menus in a brief overview. Among other things Slashdot Menu and Sexy Sliding Menu displayed below.

CSS Menu

25. CSS Pricing Matrix
A CSS-based matrix in which clicking on a highlights the associated cell in the top row and left column giving an indication of relationships among the provided information. Similar solution: Tablecloth.

CSS Pricing Matrix

26. CSS List Expander
So, we have an unordered list that can go on in depth as much as we want. The script analyzes the list tree and applies toggle functions for expanding/collapsing child objects.

List Expander

27. How to create VISTA style toolbar with CSS
Reproducing Vista toolbar, with buttons and hover effect in cross-browser compatible CSS and (X)HTML.

Vista CSS Toolbar

28. Fade Out Bottom
This is a demonstration of the effect where the bottom of the page seems to fade out. The technique makes use of an fixed position div (bottom: 0%) with a transparent PNG image and a high z-index value.

CSS-techniques - Fade Out Bottom

29. Scrollovers - A New Way of Linking
Everyone is familiar with hover-effects. This CSS+JavaScript-based techniques creates the Scrolleffect - not really necessary, but it’s nice to know, how it can be done.

Scrollovers

30. How to Style an A to Z Index with CSS

CSS-techniques - How to Style an A to Z Index with CSS | Smiley Cat Web Design

31. CSS List Boxes
Using a simple unordered list this experiment aligns the boxes across the page with the end result being to showcase items like services, products, or specials. One of cool thing about this — if you turn off styles — is the extractable semantics with the headings and paragraphs used.

List Boxes

32. How-to create a “Table of Contents” Navigation
In as little as 8 lines of HTML, and 5 lines of CSS, the Table Of Contents Navigation block can be integrated in your site ready for even more styling.

Table of Contents

33. CSS Recipe for Success

CSS-techniques - CSS - A Recipe for Success

34. Partial Opacity

CSS-techniques - Stu Nicholls | CSSplay | Partial Opacity

35. Simple Round CSS Links (Wii Buttons)

CSS-techniques - Simple Round CSS Links ( Wii Buttons )

36. How to make sexy buttons with CSS

CSS-techniques - How to make sexy buttons with CSS

37. CSS Pull Quotes

CSS-techniques - CSS Pull Quotes | Design Meme

38. Drop Shadow CSS

CSS-techniques - Drop Shadow CSS

39. CSS Speech Bubbles
Easy to customize speech bubbles coded in CSS and valid XHTML 1.0 strict.Tested in all major browsers.

Screenshot

40. CSS Double Lists

CSS-techniques - CSS: Double Lists | Mike’s Experiments | MikeCherim.com

41. Perspective Text with CSS

CSS-techniques - Mike’s Experiments: Archives Page | A Record of My Madness | Powered by the GreenBeast CMS RSS Newsmaker - -

42. Better Email Links: Featuring CSS Attribute Selectors
Learn how to generate code for displaying the e-mail automatically once mailto is used. CSS Attribute Selectors in action which is not supported by Internet Explorer 6 and 7.

Screenshot

43. CSS: Menu Descriptions
This is a CSS technique that could be useful if you want to give users accessible added content such as tool-tips, notifications, or alerts, without adding unnecessary clutter to your page. And since it doesn’t rely of JavaScript, it should be useful to everyone, even disabled users.

Screenshot

Further Techniques

44. CSS Transparency Settings for All Browsers

CSS-techniques - CSS Transparency Settings for All Browsers

45. Time Sensitive CSS Switcher
CSS Switching script that changes style sheet based on time of day.

46. Custom Reading Containers
This amazing little script allows the user to resize any container.

47. Eric Meyer’s CSS Reset

CSS-techniques - CSS Tools: Reset CSS

48. PNG Overlay
Create a transparent PNG overlay which can be used as a mask / frame around regular JPEG or GIF so users can upload photos without having to worry about using any graphics program to apply filters, plus it saves time.

49. Turning Lists into Trees

CSS-techniques - odyniec.net

50. Create Resizable Images With CSS

CSS-techniques - Create Resizable Images With CSS | Smiley Cat Web Design

 

Get free blog up and running in minutes with Blogsome
Theme designed by Jay of onefinejay.com