I want to show the data like funnel stack as illustrated below.
I was able to create the taper using borders, for example:
<div class="taper"></div>
and using the following CSS:
.taper {
width: 200px;
height: 0px;
border-color: lightgray transparent;
border-style: solid;
border-width: 50px 25px 0 25px;
}
Of course, the idea would be to wrap this div.taper
in a container, add other elements and position them as needed, a bit of work but doable.
However, I don't necessarily know how many lines (levels, 7 in this example) will be needed and I don't really want to do a lot of math to determine the width of each taper and so on.
If there a more bullet-proof way of doing this?
I don't want a JavaScript/jQuery based solution (trying to keep this lightweight) and would prefer to avoid background images (I may want to skin/customize the colors later and don't want to bother with image files).
Fiddle reference: http://jsfiddle.net/audetwebdesign/fBax3/
Browser support: modern browsers are fine, legacy support, as long as it degrades nicely.
Ryan,
Thanks for your code example! I took your example and changed it a bit to reflect my project needs. Maybe someone will find this helpful.
View on JSFiddle
Here's another take on it, this version is a bit more responsive: https://jsfiddle.net/ehynds/j3fL6hof
For those looking for a funnel with different colors for each layer in the stack:
http://jsfiddle.net/D9GLr/
HTML:
CSS:
I like the approach of dividing it into few divs. See the code here
I have to add code so an example:
and the CSS:
A way to create a funnel stack is with pseudoelements: with this basic markup
we could create the funnel using borders, so we can draw a kind of trapezoid as a background in this way:
The
<ul>
is 100% wide, so we could give it atext-align: center
and all the amounts are properly centeredThen the space between elements could be obtained as well with pseudoelements again:
while the tooltip text could be positioned (the
<li>
needs to haveposition: relative
defined), trying to properly adjust bothleft
andmargin-left
properties (especially for lower screen resolution, but you may use mediaqueries for this purpose), e.g.basically this example may work even on
IE8
if you change each:nth-child
with the adjacency selector (e.g.li + li + li + ... + span
)Hope it could be helpful.