css - Rounded table borders -


i implement rounded borders on table so:

.tbor {     border-width:3px;     border-style:solid;     border-color:lighten(@col-border,10%) darken(@col-border,10%) darken(@col-border,10%) lighten(@col-border,10%);     border-radius:12px; } .tbor>tr>td, .tbor>thead>tr>td, .tbor>tbody>tr>td, .tbor>tfoot>tr>td, .tbor>tr>th, .tbor>thead>tr>th, .tbor>tbody>tr>th, .tbor>tfoot>tr>th {     border: 1px solid @col-border;     padding: 2px; } .tbor_tl {border-top-left-radius: 8px;} .tbor_tr {border-top-right-radius: 8px;} .tbor_br {border-bottom-right-radius: 8px;} .tbor_bl {border-bottom-left-radius: 8px;} 

this works fine, requires me manually set classes on top-left, top-right, bottom-left , bottom-right cells.

on project, have used following rules cells:

.tbor>thead>tr:first-of-type>td:first-of-type,.tbor>colgroup+tbody>tr:first-of-type>td:first-of-type,.tbor>tbody:first-child>tr:first-of-type>td:first-of-type,.tbor>tr:first-of-type>td:first-of-type{border-top-left-radius:8px} .tbor>thead>tr:first-of-type>td:last-of-type,.tbor>colgroup+tbody>tr:first-of-type>td:last-of-type,.tbor>tbody:first-child>tr:first-of-type>td:last-of-type,.tbor>tr:first-of-type>td:last-of-type{border-top-right-radius:8px} .tbor>tbody:last-child>tr:last-of-type>td:first-of-type,.tbor>tfoot>tr:last-of-type>td:first-of-type,.tbor>tr:last-of-type>td:first-of-type{border-bottom-left-radius:8px} .tbor>tbody:last-child>tr:last-of-type>td:last-of-type,.tbor>tfoot>tr:last-of-type>td:last-of-type,.tbor>tr:last-of-type>td:last-of-type{border-bottom-right-radius:8px} 

it's ugly mess, , relies entirely on table cells being 1x1. falls apart when of cells (escpecially bottom ones) having colspan or rowspan.

is there way this? javascript okay: can assumed table static, or dynamic tables have static first , last rows.

jsfiddle demo

kind of interesting situation. non trivial part comes identifying bottom right corner table cell of table. others can found through conventional means.

i not sure if cleaner approach. also, used jquery (sorry) offset functionality. function can taken if not include jquery in code, example, , little brevity, used it.

this approach sort 4 corners based off of min/max top , left position relation page.

(function (){ var tl = {};tl.x=99999;tl.y=99999; var tr = {};tr.x=0;tr.y=99999; var bl = {};bl.x=99999;bl.y=0; var br = {};br.x=0;br.y=0; $(".tbor td").each(function(){     var cur = $(this).offset();     if( cur.top <= tl.y && cur.left <= tl.x ){      tl.x = cur.left;      tl.y = cur.top;      tl.td = this;     }     if( cur.top <= tr.y && cur.left >= tr.x ){      tr.x = cur.left;      tr.y = cur.top;      tr.td = this;     }     if( cur.top >= bl.y && cur.left <= bl.x ){      bl.x = cur.left;      bl.y = cur.top;      bl.td = this;     }     if( cur.top >= br.y && cur.left >= br.x ){      br.x = cur.left;      br.y = cur.top;      br.td = this;     } }); tl.td.classname += " tbor_tl"; tr.td.classname += " tbor_tr"; bl.td.classname += " tbor_bl"; br.td.classname += " tbor_br"; })() 

anyway, suggested alternative instead of determining hand td place class on.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -