Understanding CSS Styles Clip: Understanding hidden page Elements

Source: Internet
Author: User
Tags object

On the page, we often use radio, such as sex: male, female, confidential.
But we don't like the default radio style! We'll replace it with something else.
My initial approach is to use the label display, set Radio to hide! (ie Display:none;)
When I click on the label, it also triggers the radio click event.
That is: ($ is jquery)
$ (". Label1"). Click (function () {
$ (". Radio1"). Click ();
Other code changes the style so that the label appears as (non) active
});

Firefox and Chrome are more normal, but IE has the next cup!
Further debugging, found that the original IE does not trigger the hidden elements of the event, that is, the style of "display:none;" The elements.
This time I think of jquery also has to implement this function Plug-ins! So I went to check the source code of the plug-in, nothing to find!
Then Firebug check CSS, finally, clip printed into my eyes.
Here, refer to the description on W3school: http://www.w3school.com.cn/css/pr_pos_clip.asp

Syntax: object.style.clip= "rect (0px,50px,50px,0px)"
The default value is auto
Four parameters, like other CSS styles, correspond to: top, right, bottom, left.
Based on the upper-left corner of the element positioning!
That is: (the distance between the upper and lower edges from the top, the left and right edges)
Top 0 from Upper boundary
Right edge 50 from left
Lower border from top 50
Left margin 0 to the left.
This is the range of 50x50 in the upper-left corner of the display element.

This CSS style works with the absolute positioning style, where the following two often appear together:
object.style.position= "Absolute";
object.style.clip= "rect (0px,50px,50px,0px)";

Back to our radio problem, we cannot set radio "Display:none;"
Instead, set
Position:absolute;
Clip:rect (1px, 1px, 1, 1px);

This time, radio is no longer hidden, but visible elements, but by cropping (clip), we actually can't see it, problem solved!



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.