You've seen iterations of this type of progress bar on sites like paypal. How does one go about setting this up using CSS
and jquery
? I have 4 pages and each page is a step... so 4 steps.
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Adding a timeout to a render function in ReactJS
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
What I would do is use the same trick often use for hovering on buttons. Prepare an image that has 2 parts: (1) a top half which is greyed out, meaning incomplete, and (2) a bottom half which is colored in, meaning completed. Use the same image 4 times to make up the 4 steps of the progress bar, and align top for incomplete steps, and align bottom for incomplete steps.
In order to take advantage of image alignment, you'd have to use the image as the background for 4 divs, rather than using the img element.
This is the CSS for background image alignment:
Here is how to make one:
http://24ways.org/2008/checking-out-progress-meters
Here are some inspiration examples:
http://www.smashingmagazine.com/2010/01/15/progress-trackers-in-web-design-examples-and-best-design-practices/
There are a lot of very nice answers on this page and I googled for some more, but none of the answers ticked all the checkboxes on my wish list:
So I mixed the code of several examples, fixed the things that I needed and here is the result:
I used the following CSS and HTML:
As can be seen in the example above, there are now two list item classes to take note of:
active
anddone
. Useclass="active"
for the current step, useclass="done"
for all steps before it.Also note the
data-steps="4"
in theol
tag; set this to the total number of steps to apply the correct size to all list items.Feel free to play around with the JSFiddle. Enjoy!
I have searched for a solution that will visualize process steps in my web application. I have found the following excellent write-up by Stephen A Thomas:
Tracking Progress in Pure CSS (Original Link now dead)
In his approach Thomas even gets away with just using CSS - no Javascript! In an essence the following CSS code from his article does the trick for me:
As well as HTML tags from his example (I use Grails GSP pages to generate tags and 'done/todo' class dynamically):
Hope it helps. Works pretty well for me.
UPDATE: The following (shortened) version also works well.
display: table; table-layout: fixed; width: 100%
ensure that the list items are automatically sized equally as long as the content does not overflow. There is no need to usedata-progtrckr-steps
and its associated CSS.This is how I have achieved it using purely CSS and HTML (no JavaScript/images etc.).
http://jsfiddle.net/tuPrn/
It gracefully degrades in most browsers (I do need to add in a fix for lack of last-of-type in < IE9).
I had the same requirements to create a kind of step progress tracker so I created a JavaScript plugin for that purpose. Here is the JsFiddle for the demo for this step progress tracker. You can access its code on GitHub as well.
What it basically does is, it takes the json data(in a particular format described below) as input and creates the progress tracker based on that. Highlighted steps indicates the completed steps.
It's html will somewhat look like shown below with default CSS but you can customize it as per the theme of your application. There is an option to show tool-tip text for each steps as well.
Here is some code snippet for that:
Hopefully it will be useful for somebody else as well!