• Tiếng Việt (Vietnamese)
  • English (United Kingdom)
Image-free Tooltip Pointers jQuery - A Use for Polygonal CSS
joomla template, virtuemart, phpBB styles, virtuemart, drupal theme, virtuemart, phpBB styles, virtuemart, mootools, virtuemart, phpBB styles, virtuemart, drupal theme, virtuemart, phpBB styles, virtuemart, jQuery, virtuemart, phpBB styles, virtuemart, drupal theme, virtuemart, phpBB styles, virtuemart, mootools, virtuemart, phpBB styles, virtuemart, drupal theme, virtuemart, phpBB styles, virtuemart

The Design Approach

The jQuery UI planning wiki page has several examples for the tooltips we intend to build into the library.

The challenge in executing this for jQuery UI is that we'll need to pull it off without relying on images for the triangle shapes, because the jQuery UI CSS Framework enables markup to be entirely re-themable, using an infinite combination of backgrounds, borders, corner radius, and more. Using custom images for the pointer triangles would never match the flexibility and scalability of CSS alone. Since polygonal CSS can create non-rectangular shapes without images, perhaps it can provide the means to achieve our goal.

 

Polygonal CSS works by setting an element's width to something small and then setting thick borders on less than 4 sides. To make a triangle shape, 2 of those borders have to have transparent color, essentially masking out the one visible border at an angle in attempt to connect corners.

The concept is easiest explained through a code sample. The following CSS will style a div into a red triangle:

div {
 width:0; 
 height:0; 
 border-left: 20px solid transparent; 
 border-right: 20px solid transparent;
 border-top: 30px solid red;
 border-bottom: 0;
}

 

Making Use of the CSS

Our tooltip will need two of these HTML triangles stacked on top of each other to acheive a container/border effect that matches the body of the tooltip. We've done this by using two div embedded div elements. The HTML for the entire tooltip looks like this:

 Tooltip content goes here...
 
 
 

 

As you can see, we're using some classes from the jQuery UI CSS Framework for the visual skin, but the important portions here are the "fg-" classes:fg-tooltip-pointer-down and fg-tooltip-pointer-down-inner.These two classes are used on the speech bubble triangle portion of the tooltip and its child div element. The following CSS will turn this markup into our tooltip design.

/*Tooltip and Pointer CSS*/
.fg-tooltip {
 padding: .8em;
 width: 12em;
 border-width: 2px !important;
 position: absolute;
}
.fg-tooltip .fg-tooltip-pointer-down, .fg-tooltip .fg-tooltip-pointer-down-inner {
 position: absolute; 
 width:0; 
 height:0; 
 border-bottom-width: 0;
 background: none;
}
.fg-tooltip .fg-tooltip-pointer-down { 
 border-left: 7px solid transparent; 
 border-right: 7px solid transparent;
 border-top-width: 14px;
 bottom: -14px;
 right: auto;
 left: 50%;
 margin-left: -7px;
}
.fg-tooltip .fg-tooltip-pointer-down-inner {
 border-left: 5px solid transparent; 
 border-right: 5px solid transparent;
 border-top: 10px solid #fff;
 bottom: auto;
 top: -14px;
 left: -5px;
}

 

A Demonstration

To demonstrate the full effect, we've built a demo page which simply shows and hides the tooltip element when you hover on the links below. We've also extended the CSS a little further to allow for 3 different triangle types, depending on which alignment you specify, to match our original design specs.

Abandoning images in favor of this approach allows a lot more opportunities to customize the appearance with stylesheets, and we've used the jQuery UI CSS Framework to demonstrate this flexibility. Each tooltip below is styled using a different container class from the CSS Framework (such as ui-widget-header and ui-state-error), demonstrating the unobtrusive nature of this approach.

Download:htmldrive.net/items/download/503

Nếu bạn không download được hoặc có vấn đề gì hãy viết comments vào form dưới hoặc liên hệ

Tin mới hơn:
Tin cũ hơn:

 

Recommended Web Hosting For Bloggers and Designers

I recoomended Webhostings for Bloggers and Designers because I am freelancer, working with thousand clients in the worlds. Most of them will use those hosts.

vinaora vinaora
Hostting Features:
  1. Fast, Reliable, Affordable
  2. 100% Satisfaction Guarantee
  3. And More...
Special: Reach at 20% discount and 100$ for google adwords

GET STARTED

Add comment


Security code
Refresh

vinaora

Our Website Staff

Contact Us

Xindira Tower, Tay Mo - Tu Liem Dist, Hanoi, Vietnam

Tel: +84 (4) 3 789 3 442

phpBB phpBB phpBB phpBB

Follow Us

phpBB phpBB


Favourites links

may tinh bang | callingcardsdirect.co.uk | sim so dep