Need jquery plugin suggestions for rounded corners

I wanted to know about jquery plugins, so I decided to try creating a simple rounded rectangle. I know that there are already some rounded plugins, but this is more an exercise for me than a requirement for work.

The rounded corners that I took from here . I like this sample, since it does not use images, it will be easy to change the color of the fields.

I guess I have problems with my brain around the best way to do this. I have a very rough example of this kind of work, but it just doesn’t feel good. The part that hangs me creates rounded corners around the content area. Now it takes a "content" field and adds angles around it. What are the best ways to do this?

Here is the call to make the field - $ ('# content'). roundbox ();

If this is not enough, let me know.

//
(function($)
{
jQuery.fn.roundbox = function(options)
{

    var opts = $.extend({}, $.fn.roundbox.defaults, options);

    var outer = $("<div>");
    var topBorder = $("<b class='xtop'><b class='xb1'></b><b class='xb2'></b><b class='xb3'></b><b class='xb4'></b></b>");
    var bottomBorder = $("<b class='xbottom'><b class='xb4'></b><b class='xb3'></b><b class='xb2'></b><b class='xb1'></b></b>");
    var title = $("<h1>Select Funding</h1>");
    var separator = $("<div></div>");

    $(this).append(title);
    $(this).append(separator);

    var firstElement = $(this).children()[0];
    if (firstElement != null)
    {
        title.insertBefore(firstElement);
        separator.insertBefore(firstElement);
    }

    outer.append(topBorder);
    outer.append($(this));
    outer.append(bottomBorder);

    $("#fundingAdminContainer").append(outer);


    //Add classes
    outer.addClass(opts.outerClass); //outer container
    $(this).addClass(opts.contentClass); //inner content
    title.addClass(opts.titleClass); //roundbox title
    separator.addClass(opts.lineClass); //line below title
};

$.fn.roundbox.defaults =
{
    outerClass: 'roundbox',
    contentClass: 'roundboxContent',
    titleClass: 'roundboxTitle',
    lineClass: 'roundboxLine'
};


})(jQuery);


//CSS
.roundbox
{
float:left;
width:400px;
margin-right:20px;
}

.roundboxContent
{
display:block;
background:#ffffff;
border:0 solid #D4E2FE;
border-width:0 1px;
height:180px;
padding:10px;
}

.roundboxLine
{
background: url(../images/fundingAdmin_line.gif);
background-repeat:no-repeat;
height:5px;
}

.roundboxTitle
{
font-size:1.3em; color:#17A2D3;
}

.xtop, .xbottom {display:block; background:transparent; font-size:1px;}
.xb1, .xb2, .xb3, .xb4 {display:block; overflow:hidden;}
.xb1, .xb2, .xb3 {height:1px;}
.xb2, .xb3, .xb4 {background:#ffffff; border-left:1px solid #D4E2FE; border-right:1px solid #D4E2FE;}
.xb1 {margin:0 5px; background:#D4E2FE;}
.xb2 {margin:0 3px; border-width:0 2px;}
.xb3 {margin:0 2px;}
.xb4 {height:2px; margin:0 1px;}

The final structure of the box should be:

<div id="fundingAdminContainer"><!-- Not part of rounded box, just serves as a container. -->
    <div class="roundbox">
        <b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b>
        <div id="content" class="roundboxContent">
            <h1 class="roundboxTitle">Title</h1>
            <div class="roundboxLine"></div>
                //CONTENT
        </div>
        <b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b></b>
    </div>
</div>
+5
source share
5 answers

http://www.curvycorners.net/ http://www.curvycorners.net/

javascript library, not jQuery plugin, but it seems to work: D

+2
source

The way you do this seems good to me. I would not hardcode the material for funding, though.

You can make a header and a separator in function parameters, and instead of adding to #fundingAdminContainer you can do

outer.insertBefore($(this));

before adding $ (this) to the external.

EDIT: , , . border-radius CSS , , . , js, polyfill , CSS (, ). , , , this , :).

, < IE9, - this, CSS , IE ( htc) .

, htc , , - this. Htc - JS. IE9 JS DOM.

+1

here is an alternative jquery rounded plugin

http://labs.parkerfox.co.uk/cornerz/

+1
source

It is excellent:

http://jrc.rctonline.nl/

It uses Canvas, so it is very flexible.

+1
source

This jQuery Corner plugin can be useful. Easy to use and awesome.

http://jquery.malsup.com/corner/

Using

$('#myDiv').corner();
0
source

All Articles