Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Round thead corners in Firefox with CSS

Tags:

html

css

I would actually want to round thead's corners within a table. It doesn't seems to be possible as far as I'm concerned. I have tried almost everything but I couldn't get it work.

The problem is that I basically have a table which's thead has a particual color, let's say black, and I'd like to give it a little rounding by rounding it's corners.

Can anyone please tell me how is it possible?

Here is the jsFiddle I have tried so far:

HTML:

    <table>
    <thead>
        <tr>
            <th>First</th>
            <th>Second</th>
            <th>Third</th>
        </tr>
    </thead>
</table>

CSS:

table {
    margin: 0px auto;
    clear: both;
    width: 100%;
    border: 1px solid white;
   -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    border-radius: 3px;
    color: white;
}

table thead {
    background: black;
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    border-radius: 3px;
}

http://jsfiddle.net/fhyWp/2/

like image 787
RadicalActi Avatar asked Jul 03 '13 14:07

RadicalActi


People also ask

How do I round the corners of a table in CSS?

Use the CSS border-radius property to add rounded corners to the table cells.

How do I make rounded corners with buttons in CSS?

To create a rounded button you have to make use of the border-radius CSS property. The higher the value for that property the more rounder the corners will be. You can use any CSS unit for the boorder-radius property. It can be pixels, ems, rems, percentages etc.

Which of the CSS property below will allow you to apply rounded corners?

In CSS, the way you specify rounded corners is via the border-radius property that, in its simplest form, takes a value defining the radius of the rounding: border-radius : 10px ; In the above line, I am specifying a radius of 10px that gets applied to all corners.


2 Answers

EDIT in 2020 as I've seen some activity on this answer recently.

These days you should just use the border-radius property as all the major browser now support it.

th {
    border-radius: 3px;
}

Because the radius needs to be on th not on thead. Add something like:

th {
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
}

(you could remove the border radius info from table thead)

Also works if you just change table thead to th

If you have borders, the table's border-collapse css property must be set to 'separate'.

table{
    border-collapse: separate;
}
like image 184
Cfreak Avatar answered Oct 03 '22 20:10

Cfreak


  table  th:nth-child(1){

    /* Safari 3-4, iOS 1-3.2, Android 1.6- */
    -webkit-border-radius: 3px 0px 0px 3px; 

    /* Firefox 1-3.6 */
    -moz-border-radius: 3px 0px 0px 3px; 
  
    /* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, iOS 4, Android 2.1+ */
    border-radius: 3px 0px 0px 3px; 
    }

    table  th:nth-last-child(1){
      /* Safari 3-4, iOS 1-3.2, Android 1.6- */
      -webkit-border-radius: 0px 3px 3px 0px; 

      /* Firefox 1-3.6 */
      -moz-border-radius: 0px 3px 3px 0px; 
  
      /* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, iOS 4, Android 2.1+ */
      border-radius: 0px 3px 3px 0px;
}

Fiddle

like image 28
Abdul Malik Avatar answered Oct 03 '22 19:10

Abdul Malik