border-Radius in table does not work CSS

Asked

Viewed 10,234 times

5

I’m trying to put a Radius border on my table so that the four tips of it are rounded. If I touch the tr/th/td border-Radius it will change the radius of the ballots and not only those of the table, which is my goal and if I change the radius of the table and this appears correctly. With the table marks that the radius decreased but the table does not follow this, follows an image to illustrate what I said:

inserir a descrição da imagem aqui

CSS:

    .table-round-corner{
    margin-top: 15px;
    width: 100%;
    text-align: center;
    berder-radius: 25px;
    border: solid #ddd 1px;
    overflow:hidden;
}
table td{
    color: #aaa;
    background-color: white;
    padding: 5px;
    border: 1px solid #ddd;
}
table th{
    color: white;
    background-color: red;
    font-weight: normal;
    text-align: center;
    padding: 5px;
    font-size: 12px;
}

HTML:

                    <table class"table-round-corner">
                        <tr>
                            <th>ASDASD</th>
                            <th>ASDASDAS</th>
                            <th>ASDASD</th>
                        </tr>
                        <tr>
                            <td>ASDASD</td>
                            <td>34</td>
                            <td>R$ 00,00</td>
                        </tr>
                        <tr>
                            <td>ASDASDASD</td>
                            <td>00</td>
                            <td>R$ 00,00</td>
                        </tr>
                    </table>

Summary:

I need my table to have rounded ends.

  • 1

    It doesn’t work because you’re not applying the rule in the table.

  • Ah no, "berder-radius: 25px;".

3 answers

7


Long live!

I think this is what you want:

.table-round-corner {
    margin-top: 15px;
    width: 100%;
    text-align: center;
    overflow:hidden;
    border-collapse:separate;
    border: solid #ccc 1px;
    -webkit-border-radius: 25px;
       -moz-border-radius: 25px;
            border-radius: 25px;
}


table td {
    color: #aaa;
    background-color: white;
    padding: 5px;
    border: 1px solid #ddd;
}

table th{
    color: white;
    background-color: red;
    font-weight: normal;
    text-align: center;
    padding: 5px;
    font-size: 12px;
}
<table class="table-round-corner" cellspacing="0">
  <tr>
    <th>ASDFASDF</th>
    <th>ASDFASDFASDFA</th>
    <th>ASDFASDF</th>
  </tr>
  <tr>
    <td>ASDFASDF</td>
    <td>654</td>
    <td>R$ 00,00</td>
  </tr>
  <tr>
    <td>SDFASDF</td>
    <td>45</td>
    <td>R$ 00,00</td>
  </tr>
</table>

  • 1

    Can you show me 1 print of how it is? Just to try to understand better why it didn’t work.

  • 1

    Can you open the browser’s Developer Tools and select the element to see the css rules that are being applied? In the meantime I have changed the CSS of class . table-round-corner, please check if it already works.

  • There is! I found the problem! Probably before, it was not showing up properly because of the overflow and now it was written berder-Radius (which I don’t know how I copied your code O.O).

5

Just apply on the table.

table {
  border: 2px solid #ccc;
  border-radius: 5px;
}
<table>
  <tr>
    <td>foo</td>
    <td>foo</td>
    <td>foo</td>
  </tr>
  <tr>
    <td>foo</td>
    <td>foo</td>
    <td>foo</td>
  </tr>
</table>

Since you are (apparently) using Bootstrap, you can try this way:

/* só para manter a tabela centralizada */
.panel {
  margin: 10px auto;
  max-width: 70% !important
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">

<div class="panel panel-default">
  <table class="table table-bordered">
    <tr>
      <td>foo</td>
      <td>foo</td>
      <td>foo</td>
    </tr>
    <tr>
      <td>foo</td>
      <td>foo</td>
      <td>foo</td>
    </tr>
  </table>
</div>

If it still doesn’t work it may be that some other rule is overriding the border-radius. In that case, you can try it this way:

.table {
   border-radius: 5px !important
}

!Mportant - Maujor

  • I tried using the ! Mportant and was not

  • I edited the topic the way it is now and it still doesn’t work, I also tried putting CSS in the table{} and it didn’t work.

3

I don’t understand exactly what you want. Would that be?

HTML

<table class="borda-na-tabela">
<tr>
<th>ASDFASDF</th>
<th>ASDFASDFASDFA</th>
<th>ASDFASDF</th>
</tr>
<tr>
<td>ASDFASDF</td>
<td>654</td>
<td>R$ 00,00</td>
</tr>
<tr>
<td>SDFASDF</td>
<td>45</td>
<td>R$ 00,00</td>
</tr>
</table>

CSS

.borda-na-tabela {
    margin-top: 15px;
    width: 100%;
    text-align: center;
    overflow:hidden;
    border-collapse:separate;
    border: 3px solid red;
    border-radius: 50%;
}

table td {
    color: #aaa;
    background-color: white;
    padding: 5px;
    border: 1px solid #ddd;
}

table th{
    color: white;
    background-color: red;
    font-weight: normal;
    text-align: center;
    padding: 5px;
    font-size: 12px;
}

Jsfiddle

  • your answer is not the same as @Helder?

  • 1

    @Andreyhartung Now that I’ve noticed that it’s pretty much the same. But the point is that stop what you asked for, the way you asked, that’s what meets it. The difference seeing running, is that my code generates a table as per the div of your example.

  • The tricky thing is that I have already left so and still do not appear the x.x borders

  • @Andreyhartung You have your application running on some link?

  • unfortunately not and still can not put on air :/ I will edit here as it is now

  • I edited the topic the way it is now and it still doesn’t work, I also tried putting CSS in the table{} and it didn’t work.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.