2016-07-18 20 views
0

まず:tr:ホバーのボーダー半径を<tr>にするには?私は私がしたいことはある、それは<code><table></code>が含まれている大きな<code><div class="content"></code>を持って

  • テーブル(またはコンテンツ)すべての行にカーソルを渡すときの国境半径(10pxの)
  • を必要とします(ありません<table>ちょうど<tr>:背景色の変更(それは大丈夫だ)が、コンテンツが国境半径を維持する必要がある(それは今のところ大丈夫ではありません - >これは私の質問です)

BORDER-を作る方法<div class=content">の半径が表示されています(trは "over"です単純なスクリプトがされ、それに乗っと境界半径は、ここ)ホバーに

を消失(イエロー色は灰色1ホバー=同一の幅と同じ境界半径)

.content{ 
 
    width:100%; 
 
    height:auto; 
 
    border-radius:10px; 
 
    background-color:gray; 
 
} 
 

 
table{ 
 
    width:100%; 
 
    cursor:pointer; 
 
} 
 

 
tr{ 
 
    width:100%; 
 
    border-radius:10px !important; 
 
} 
 

 
table tr:hover{ 
 
    background-color:gold; 
 
    border-radius:10px; 
 
}
<div class="content"> 
 
<table> 
 
<tr> 
 
    <td>hello</td> 
 
    <td>world</td> 
 
</tr> 
 
</table> 
 
</div>
と同じである必要があります

答えて

1

border-radiusは、td要素に適用する必要があります。

境界線の半径を適用するには、:first-child:last-childセレクタを使用します。

.content { 
 
    width: 100%; 
 
    height: auto; 
 
    border-radius: 10px; 
 
    background-color: gray; 
 
} 
 
table { 
 
    width: 100%; 
 
    cursor: pointer; 
 
} 
 
tr { 
 
    width: 100%; 
 
    border-radius: 10px !important; 
 
} 
 
table tr:hover { 
 
    background-color: gold; 
 
    border-radius: 10px; 
 
} 
 
table tr:hover td:first-child { 
 
    border-top-left-radius: 10px; 
 
    border-bottom-left-radius: 10px; 
 
} 
 
table tr:hover td:last-child { 
 
    border-top-right-radius: 10px; 
 
    border-bottom-right-radius: 10px; 
 
}
<div class="content"> 
 
    <table> 
 
    <tr> 
 
     <td>hello</td> 
 
     <td>world</td> 
 
    </tr> 
 
    </table> 
 
</div>

+0

アメージング!良いですね! – mattvent

-1

HTML:

<div class="content"> 
<table> 
<tr> 
    <td>hello</td> 
    <td>world</td> 
</tr> 

</table> 
</div> 

CSS:

.content{ 
    width:100%; 
    height:auto; 
    border-radius:10px; 
    background-color:gray; 
} 

table{ 
    width:100%; 
    cursor:pointer; 
} 

tr:first-child td:first-child { border-top-left-radius: 10px; } 
tr:first-child td:last-child { border-top-right-radius: 10px; } 
tr:last-child td:first-child { border-bottom-left-radius: 10px; } 
tr:last-child td:last-child { border-bottom-right-radius: 10px; } 

table tr:hover{ 
    background-color:gold; 
    border-radius:10px; 
} 
+0

ここにコードを追加して下部を追加し、フィドルにリンクを追加します。今は低品質レビューです。 – NSNoob

+0

@Adi: 'tr:first-child td:first-child'は最初の行の最初の列に対してのみ機能します。複数の行がある場合はどうなりますか? – Pugazh

+0

これを確認してくださいhttps://jsfiddle.net/eradi_singh/05mzwaLp/それで私はなぜそれに答えたのかを知るようになりました – mean

0

あなたが上でもborder-radiusが必要それは

を助けている場合、その色は、私が最後td

に最初tdborder-top-right-radiusborder-bottom-right-radiusborder-top-left-radiusborder-bottom-left-radiusを入れている

TRの半径上で起こっている理由ですtdは私に知らせてあなたはを適用する必要が

.content{ 
 
    width:100%; 
 
    height:auto; 
 
    border-radius:10px; 
 
    background-color:gray; 
 
} 
 

 
table{ 
 
    width:100%; 
 
    cursor:pointer; 
 
} 
 

 
tr{ 
 
    width:100%; 
 
    border-radius:10px !important; 
 
} 
 
td:last-child { 
 
    -webkit-border-top-right-radius: 10px; 
 
    -webkit-border-bottom-right-radius: 10px; 
 
    -moz-border-radius-topright: 10px; 
 
    -moz-border-radius-bottomright: 10px; 
 
    border-top-right-radius: 10px; 
 
    border-bottom-right-radius: 10px; 
 
} 
 
td:first-child{ 
 
    -webkit-border-top-left-radius: 10px; 
 
    -webkit-border-bottom-left-radius: 10px; 
 
    -moz-border-radius-topleft: 10px; 
 
    -moz-border-radius-bottomleft: 10px; 
 
    border-top-left-radius: 10px; 
 
    border-bottom-left-radius: 10px; 
 
} 
 

 
table tr:hover{ 
 
    background-color:gold; 
 
    border-radius:10px; 
 
}
<div class="content"> 
 
<table> 
 
<tr> 
 
    <td>hello</td> 
 
    <td>world</td> 
 
</tr> 
 
</table> 
 
</div>

0

trタグではなく、tdタグにを追加してください。

  • 最初の行の最初のセルの左上、
  • トップ:複数のセルを含む各、あなたがあなたのテーブルに複数の行を持っていると仮定すると、あなたはborder-radius 4に異なるセルを適用する設定する必要があります
  • 最後の行の最初のセルの左下と、
  • 最後の行の最後のセルの右下に表示されます。

は、ここではそうだろう方法は次のとおりです。

table{ 
 
    background:gray; 
 
    border-radius:10px; 
 
    width:100%; 
 
} 
 
tr:hover>td{ 
 
    background:gold; 
 
} 
 
tr:first-child>td:first-child{ 
 
    border-top-left-radius:10px; 
 
} 
 
tr:first-child>td:last-child{ 
 
    border-top-right-radius:10px; 
 
} 
 
tr:last-child>td:first-child{ 
 
    border-bottom-left-radius:10px; 
 
} 
 
tr:last-child>td:last-child{ 
 
    border-bottom-right-radius:10px; 
 
}
<table> 
 
    <tbody> 
 
    <tr> 
 
     <td>Lorem</td> 
 
     <td>Ipsum</td> 
 
     <td>Dolor</td> 
 
    </tr> 
 
    <tr> 
 
     <td>Lorem</td> 
 
     <td>Ipsum</td> 
 
     <td>Dolor</td> 
 
    </tr> 
 
    <tr> 
 
     <td>Lorem</td> 
 
     <td>Ipsum</td> 
 
     <td>Dolor</td> 
 
    </tr> 
 
    </tbody> 
 
</table>

関連する問題

 関連する問題