Here is another improvement made to the shop
Treasures of the Dragon during The revamp: an indicator that makes it immediately clear to what extent the customer's buying process is. This is a progress-bar
that makes its appearance in the shopping cart page, and indicates how many steps are still needed before concluding the purchase. On each page is shown the current step.
In reality this is not only an improvement, but also a feature request in accordance with the standards of clarity and transparency that govern electronic commerce.
\u0026lt;div id="checkoutbar">
This
progress-bar is made entirely with CSS and a bit of jQuery, plus four icons PNG (or GIF), one for each step.
You could also use only the CSS, but I also use a bit 'of jQuery to show the power of its selectors.
1. HTML markup
First you must create bar elements, placing them in valid and accessible HTML page:
\u0026lt;ol>
\u0026lt;li> Cart \u0026lt; , / li> \u0026lt;li> Data Entry \u0026lt;/ li> \u0026lt;li> Order Summary \u0026lt;/ li>
\u0026lt;li> Order Complete \u0026lt;/ li> \u0026lt;/ ol> \u0026lt;/ div>
An ordered list is ideal for a logical sequence of steps.
2. Add CSS to taste
now have the style to create four blocks lined up and not typical of the rows of the lists, other more basic style to make the bar more attractive and in line with the design of the site.
# checkoutbar
{margin: 0 auto;
- padding: 0;
- height: 50px; width: 700px;} # checkoutbar ol {list-style-type: none; margin: 0 auto; } # checkoutbar
- li {float: left; font-size: .6 em; margin: 1em; padding: 1em 2em;
- background: # Abdbff; border: 3px solid # abdbff; -moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px;
opacity: .7; filter: alpha (opacity = 70);}
propertyfloat: left
-list given to the elements means that they have next to one another. The spacing is achieved with appropriate padding and margins.
Note the rounded corners (border-radius property
, CSS3) for browsers that support them (such as Firefox and Safari ... not IE, as usual!): The first statement, the one with
this article for an explanation of the nature of these statements.
Other interesting attribute is the opacity, which needs two settings: the first (adhering to the guidelines of CSS3
) is not valid for the usual IE, which wants to attribute
filter: alpha .
transparency we need to focus even more attention on the user's steps when he is present, which will be made later completely opaque ( opacity: 1 ).
3. Style of the current step
At this point the choices are two, rather equivalent:
a class attribute on each page list the item on, for example with a class = "current" and create a style
only on that class.
use jQuery selectors, and create a way through them.
Today we go to the second street, just to see a couple of selectors work.
Here's the code:
$ (document). Ready (function () {
$ ('# checkoutbar li: not (: last)'). Append ('> >') ;
$ ('# checkoutbar li: eq (0)'). css ({
'opacity': '1 ', ' padding-left ' : '40px ', ' background ':' # 0081e4 url \u200b\u200b(images/checkoutbar1.png) center left no-repeat ',
' color ':' # fff ',
' border ': '3 px # abdbff double' });}
)
: This value should be changed on each page on which the figure of our bar.
The first statement is used to attach names to all steps of the two symbols "greater than (>), to take the place of an arrow pointing to a path. I preferred using jQuery inseririli because they have no meaning in the strict sense, but I'm just a simple device design, and the markup on our list is clean. The selector
not () is a
override, that is a Logical NOT, while
last
identifies the last element of a series, in this case the number of tags
\u0026lt;li>
.
In this way, the last step, which is the end of the Route, has no associated arrow.
The rest of the current style is identified with the selector
eq (index)
: it identifies a part of a series based on its index, which starts at 0. In this case, being the first element of the current one, we
. Eq (0)
The image which is referenced in the background is an icon that identifies the current stage, also for each individual phase.
0 comments:
Post a Comment