Sliding DOORS Effect

xiaoxiao2021-03-05  28

Skip navigation.

Up FrontArticlesabout alalive eventsxml feeds

Issn: 1534-0295. 20 October 2003 - Issue No. 160

Sliding DOORS OF CSS

By Douglas Bowman

A rarely discussed advantage of CSS is the ability to layer background images, allowing them to slide over each other to create certain effects. CSS2's current state requires a separate HTML element for each background image. In many cases, typical markup for common interface components has Already Provided Several Elements for Our Use.

One of those cases is tabbed navigation. It's time to take back control over the tabs which are continually growing in popularity as a primary means of site navigation. Now that CSS is widely supported, we can crank up the quality and appearance of the tabs on You Sites. You're Most Likey Aware That CSS Can Be Used to Tame A Plain Unordered List. Maybe You've Even Seen Lists Something Like THIS:

What if We Could Take The Exact Same Markup from The Tabs Above, and Turn Them Into Something Like this:

WITH SIMPLE STYLING, WE CAN.

WHERE's the innovation?

Many of the CSS-based tabs I've seen suffer from the same generic features:. Blocky rectangles of color, maybe an outline, a border disappears for the current tab, a color changes for the hover state Is this all CSS can offer us ? A Bunch of Boxes and flat colors?

Prior to a more widespread adoption of CSS, we started seeing a lot of innovation in navigation design. Creative shapes, masterful color blending, and mimicry of physical interfaces from the real world. But these designs often relied heavily on a complex construction of text- embedded images, or were wrapped with multiple nested tables. Editing text or changing tab order involved a cumbersome process. text resizing was impossible, or caused significant problems with page layout.Pure text navigation is much easier to maintain and loads more quickly than text- as-image navigation. Also, even though we can add alt attributes to each image, pure text is even more accessible since it can be resized by users with impaired vision. It's no wonder that pure text-based navigation, styled with CSS, is Leaping Back Into Web Design So Far Is A Step Back In Appearance from What Weisting To Do - Certainly Nothing to Be Included In A Design Portfolio. A Newly Adopted Techno LOGY (LIKE CSS) SHOULD Allow US To Create Sometting Better, WITHOUT LOSIING The Design Quality of Previous Table Hacks and all-image-based tabs.

The Sliding Doors Technique

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. One for the left, one for the right. Think of these two images as Sliding Doors that complete one doorway The DOORS SLIDE TOGETHER AND OVERLAP MORE TO FILL A Narrow Space, or Slide Apart and Overlap Less To Fill A Wider Space, as The Diagram Below Shows:

With this model, one image covers up a portion of the other. Assuming we have something unique on the outside of each image, like the rounded-corner of a tab, we do not want the image in front to completely obscure the image behind it. to prevent this from happening, we make the image in front (left-side for this example) as narrow as possible. But we keep it just wide enough to reveal that side's uniqueness. If the outside corners are rounded, we should make the front image only as wide as the curved portion of the image: If the object grows any larger than the width shown above, due to differing text or type size changes, the images will get pulled apart, creating an ugly gap We need to. make an arbitrary judgment about the amount of expansion we'll accommodate. How large do we think the object might grow as text is resized in the browser? realistically, we should account for the possibility of our tab text increasing by at least 300%. WE NEED TO Expand The Background Images to Compens .

Keep in mind that background images only show in the available "doorway" of the element to which they're applied (content area padding). The two images are anchored to the outside corners of their respective elements. The visible portions of these background Images Fit Together Inside The Doorway To Form A Tab-Like Shape:

If the Tab Is Forced to a Larger Size, The Images Slide Apart, Filling A Wider Doorway, Revealing More of Each Image:

For this example, I used Photoshop to create two smooth, slightly three-dimensional, custom tab images shown at the beginning of this article For one of the tabs, the fill was lightened and the border darkened -. The lighter version will be used to represent the "current" tab Given this technique's model for left and right tab images, we need to expand coverage area of ​​the tab image, and cut it into two pieces:.. The same thing needs to happen with the lighter current tab image Once WE Have All Four images Created, (1, 2, 3, 4) We can Jump INTO The Markup and CSS for Our Tabs.

Tab Creation

As you explore the creation of horizontal lists with CSS, you'll notice at least two methods for arranging a group of items into one row. Each comes with its own benefits and drawbacks. Both require dealing with rather funky aspects of CSS which quickly become Confusing. ONE Uses the inline box, The Other Uses floats.

The First Method - and possibly the more common - is to change the display of each list item to "inline" The inline method is attractive for its simplicity However, the inline method causes a few rendering problems in certain browsers for the Sliding Doors.. technique we're going to discuss. The Second Method, which is the one we'll focus on, uses floats to place each list item in a horizontal row. floats can be equally frustrating. Their seemingly inconsistent behavior circumvents all natural logic. Still A Basic Understanding of How To Deal With Multiple Floated Elements, And The Means To Reliably "Break Out" of floats (or contain theme) can achieve wonders.

We're going to nest several floated elements within another containing floated element. We do this so that the outer parent float completely wraps around the floats inside. This way, we're able to add a background color and / or image behind our tabs . It's important to remember that the next element following our tabs needs to reset its own position by using the CSS clear property This prevents the floated tabs from affecting the position of other page elements.Let's begin with the following markup.:

转载请注明原文地址:https://www.9cbs.com/read-32846.html

New Post(0)