CSS + jquery

Source: Internet
Author: User
Tags jquery library

So I want to use a method that is convenient to call and update, and the result is as expected. The technical points are summarized as follows:

Before that, I have also looked for implementation solutions for the most popular practices on the network. I have summarized seven methods in total, but found that their methods are more or less flawed, later, I made a method that I felt satisfied.
First, let's look at the seven most popular practices on the Internet:
1. No image CSS rounded corner box

Reason: strong compatibility, no need for graphics

Figure 1

Features:

1. Without any graphics, use multiple Div containers to simulate the rounded corner effect.

2. Compatibility: Kill all browsers

Disadvantages:

1. Too many non-semantic labels are required to construct the rounded corner. The structure is redundant.

2. Poor reusability: If a page has multiple rounded corners and different radius sizes are required, the flexibility is not enough.

3. Although the border color can be adjusted, it will have a fatal impact on the structure of the page. It is suitable for pages with a single color and few rounded corners on a page.

4. It is not easy to implement a gradient image background in the ARC.

5. The rounded corner frame is not smooth enough and has a sawtooth image. It is suitable for webpages with a small background color and a small arc.

Implementation principle:

Use a lot of Div containers with a height of 1 pixel, and use the background color and border color to simulate the contour of the rounded corner frame.

Example: http://www.cssplay.co.uk/boxes/snazzy.html

2. There is no image-only CSS rounded corner box, with special characters (& bull)

Reason for recording: Smooth, no need for graphics

Figure 2

Features:

1. Use special characters • (DOTS) to simulate rounded corners without any graphics.

2. Compatibility: Kill all browsers

3. smooth rounded corners

Disadvantages:

1. To construct this rounded corner, add a non-semantic tag. The structure is redundant, the same as the first one.

2. Poor reusability: If a page has multiple rounded corners and different radius sizes need to be achieved, you need to adjust the positioning of the four angle images, and the character size has an impact on them, and the flexibility is not enough.

3. Although the color can be adjusted, the background color must be the same as the Character Color and cannot be used as a border line. It is applicable to pages with a single color and not many rounded corners in a page.

4. It is not easy to implement a gradient image background in the ARC.

Implementation principle:

Use special characters (& bull) to capture a corner image of the rounded corner frame in 1/4.

Example: http://www.cssplay.co.uk/boxes/curves.html

3. Image rounded corner

Reason for inclusion: strong compatibility and complicated rounded corner effects.

Figure 3

Features:

1. Use four rounded corners (or a circular image ).

2. Compatibility: removes all browsers.

3. This is the most common rounded corner frame practice.

4. Because the image is used for display, the rounded corner is super smooth and there is no sawtooth phenomenon.

5. Rich performance, suitable for all kinds of corner boxes with high image performance requirements.

Disadvantages:

1. To construct the rounded corner, you also need to add four labels to hold four angle images. The structure is also redundant.

2. Poor reusability: If a page has multiple rounded corners with different radius sizes, You need to recreate a set of rounded corner images.

3. If there is no special need for structure redundancy, This is the super smooth rounded corner box solution.

Implementation principle:

Based on the jiugongge principle, add four rounded corner images with absolute positioning (or relative positioning) to the four corners of a container.

Example: http://www.cssplay.co.uk/boxes/three_cornered.html

4. Use VML to draw rounded corners (ie Only)

Reason for recording: no image, smooth, shadow border added

Figure 4

Features:

1. No graphics are needed.

2. Compatibility: it can only be used in IE.

3. Adjust the radius of the rounded corner at will

4. High reusability: Multiple rounded corners can be called at will.

5. Set the rounded corner color at will.

6. No redundant structure.

7. The rounded corner is smooth and non-sawtooth.

Disadvantages:

1. In addition to compatibility problems, other aspects of performance are good.

2. You cannot add a wide range of gradient images to an arc because the arc frame is transparent.

Implementation principle: Use VML for IE to draw rounded corners.

<V: roundrect

Id = "roundbox"

Class = "circle"

Strokecolor = "red"

Strokeweight = "2px"

Arcsize = "0.08">

</V: roundrect>

Note:

<HTML xmlns: V xmlns = "http://www.w3.org/5o/xhtml”> This is a compatible method. xmlns: vdefinitely cannot be small, otherwise...

Add this sentence to the style sheet:

V ": * {behavior: URL (# default # VML); display: inline-block ;}

Arcsize is the radius

Strokeweight indicates the border line width.

Strokecolor indicates the border line color.

Example: (view this instance in IE browser)

VML draws smooth rounded corners

Use VML for IE to draw a smooth rounded corner box and draw a shadow effect. Its graphic performance is perfect.

5. Use private attributes to draw rounded corners (ff3 only)

Reason: smooth and non-sawtooth

Figure 5

Features:

1. No graphics are needed.

2. Compatibility: it can only be used in ff3. other browsers are not supported.

3. Adjust the radius of the rounded corner at will

4. High reusability: Multiple rounded corners can be called at will. You only need to set the style sheet.

5. Set the rounded corner color at will.

6. No redundant structure.

7. The rounded corner is smooth and non-sawtooth.

Disadvantages:

1. in addition to compatibility issues, other aspects of the performance are good, this method should be the most perfect way, but at present only ff3 can support this attribute, it will be supported in the future css3, but I don't know how many years later.

2. Like the fifth rounded corner, it seems powerless to process the image background in the ARC.

Implementation principle:

Use the private attributes of ff3 to draw rounded corners.

Only two attributes are used to show the smooth rounded corner frame.

-Moz-border-radius: 10px;

Border: 5px red solid;

Instance Demonstration: (Please watch in ff3 browser, not supported by other browsers)

Ff3 rounded corner box for private attribute painting

Two attributes of the rounded corner box under ff3 can be solved:

-Moz-border-radius: radius

Border: border

6. No image script rounded corner box (JS semi-perfect solution)

This solution should be a perfect solution now.

Figure 6

Features:

1. No graphics are needed.

2. Compatibility: Kill all browsers

3. Adjust the radius of the rounded corner at will

4. High reusability: Multiple rounded corners can be called at will.

5. You can set the color at will, and use complex images as the background for rich performance.

6. No redundant structure. You only need to define a class or ID on the container to convert the DIV into a rounded corner.

7. smooth rounded corners.

Disadvantages:

1. When the client disables JS, there is no rounded corner. However, in the current situation, this situation should not become a big problem.

Example Demo: http://www.curvycorners.net/examples.php (with three demo examples)

7. No rounded corner frame in combination with image VML/canvas

Add a scheme that combines jquery/VML/canvas's no-image rounded corner frame.

Figure 7

Features:
1. No graphics are needed.
2. Compatibility: Kill all browsers
3. Adjust the radius of the rounded corner at will, and set the four corners as needed.
4. High reusability: Multiple rounded corners can be called at will.
5. You can set the color at will, and use complex images as the background for rich performance.
6. No redundant structure. You only need to define a class or ID on the container.
7. smooth rounded corners.
Disadvantages:
1. the jquery library and a JS file are used for this rounded corner. If jquery is used in your project, it can be used. Otherwise, loading one or two JS files into a rounded corner is not worth the candle.
2. the rounded corner is displayed in different browsers.
Example: http://labs.parkerfox.co.uk/cornerz/

Conclusion: currently, CSS cannot define multiple background images for a container, leading to redundant labels for this effect. It is said that css3 will introduce this attribute. It may be time to unify the rounded corners. In addition, I also heard that css3 intends to add methods like ff3 private attributes (-moz-border-radius), which can perfectly solve this problem. However, in the current situation, we may only use these methods to make the transition. We strongly look forward to the arrival of css3.

All in all: to achieve an absolute perfect rounded corner frame is basically impossible in the current situation, so it is named "semi-perfect solution ".

Else ---------------------------------------------------------------------------------------------------------------------------------

My solution: CSS + jquery + rounded corner image with four corners

Step 1: Download The jquery-1.3.2.min.js file at http://jquery.com/to reference the file.
Add <SCRIPT type = "text/JavaScript" Language = "JavaScript" src = "jquery-1.3.2.min.js"> </SCRIPT> to the page Step 2: Write the jquery method on the page that requires corner frame implementation (jquery is a framework technology of JS ).
Source code:

CopyCode The Code is as follows: <Div class = "corner2 clear">
<Div class = "bnlist detail">
<Asp: button text = "query" id = "btsearch" runat = "server" onclick = "btnsearch_click"/>
<Asp: button text = "Export" runat = "server" onclick = "btnexport_click"/>
<Asp: button text = "print" id = "btnprint" runat = "server" onclick = "btnprint_click"/>
<Asp: button text = "continuous printing" runat = "server" onclick = "btncontinueprint_click"/>
</Div>
</Div>

JS Code: copy Code the code is as follows:

Generated HTML code:Copy codeThe Code is as follows: <Div class = "Corner"> <Div class = "cortop"> <Div class = "bgcortopl"/> <Div class = "bgcortopr"/> </div>
<Div class = "bnlist detail">
<Input type = "Submit" id = "ctl00_cphcontent_btsearch" value = "query"/>
<Input type = "Submit" value = "Export" name = "ctl00 $ cphcontent $ ctl00"/>
<Input type = "Submit" id = "ctl00_cphcontent_btnprint" value = "print"/>
<Input type = "Submit" value = "continuous printing"/>
</Div>
</Div>
<Div class = "corbom"> <Div class = "bgcorboml"/> <Div class = "bgcorbomr"/> </div>

Step 3: edit the CSS style to achieve the desired rounded corner.

Summary: As long as class = "Corner" is in the source code of the DIV block to be rounded, The DIV tag to be rounded is generated by calling the JS Code, you do not need to manually add the code for each rounded corner block, which makes the work simple and the source files clear and simplified, facilitating R & D personnel and UI personnel.

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.