Webサイト制作

投稿日:

角丸テーブルのスタイル指定

時々使うテーブルの角丸仕様、毎回調べてる気がする。。

ポイントはborder-collapse
border-collapse: collapse;ではなくborder-collapse: separate;を指定します

まずはtable作成

<table class="radius_table">
  <tbody>
    <tr>
      <th>見出し(th)</th>
      <td>内容(td)</td>
    </tr>
    <tr>
      <th>見出し(th)</th>
      <td>内容(td)</td>
    </tr>
    <tr>
      <th>見出し(th)</th>
      <td>内容(td)</td>
    </tr>
    <tr>
      <th>見出し(th)</th>
      <td>内容(td)</td>
    </tr>
    <tr>
      <th>見出し(th)</th>
      <td>内容(td)</td>
    </tr>
  </tbody>
</table>

作成したtableにスタイルを追加します

 .radius_table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 10px;
  border: 2px solid #ffd783;
}

.radius_table th {
  padding: 10px;
  background: #ffd783;
  border-right: 1px solid #ffffff;
  border-bottom: 1px solid #ffffff;
  font-weight: bold;
  text-align: center;
}

.radius_table td {
  padding: 10px;
  border-right: 1px solid #ffd783;
  border-bottom: 1px solid #ffd783;
}

.radius_table td:last-child,
.radius_table th:last-child {
  border-right: none;
}

.radius_table tr:first-child>*:first-child {
  border-radius: 6px 0 0 0;
  border-left: 1px solid #ffd783;
}


.radius_table tr:first-child>*:last-child {
  border-radius: 0 6px 0 0;
  border-right: none;
}

.radius_table tr:last-child>* {
  border-bottom: none;
}

.radius_table tr:last-child>*:first-child {
  border-radius: 0 0 0 6px;
}

.radius_table tr:last-child>*:last-child {
  border-radius: 0 0 6px 0;
  border-right: none;
}

出来上がり

このような感じで角丸テーブルができます。
カラーや幅指定は任意で追加してください

見出し(th) 内容(td)
見出し(th) 内容(td)
見出し(th) 内容(td)
見出し(th) 内容(td)
見出し(th) 内容(td)

- Webサイト制作
-

関連記事

サイトのタイトルを画像置換する方法

よくやり方忘れてしまうのでメモ。 サイトのタイトルをh1とかで記述した場合 それを画像置換するための方法は色々あって 評価が分かれるので現時点でいいなと思っているものを。 まずはhtml <h1 ...

mmenuは初心者でも簡単に使えるjQuery plugin|スマホ用メニュー

スマホ用メニューを作成する時によく使っているのがjQuery pluginのmmenuあまりjQuery詳しくない私でも簡単に使えるところが気に入ってます。オプションで色々設定もできるみたいなので、初 ...

動画や連続写真からのアニメーションgifの作成

アドビのサイトにとっても分かりやすく説明されていたアニメーションgifの作り方。 連続写真や動画から簡単に作成できます。 アニメーションgifの作成方法 動画の再生やアニメーションgifのサンプル作成 ...

no image

サイト制作に役立つTips_リンク集

スタイルなどの装飾 ボタンのホバーアニメ バリエーションが豊富です。デザインのヒントに 【保存版】CSSだけで作れるホバーアニメーションボタン総まとめ 角丸とシャドウのジェネレーター 見た目で調節した ...

cssだけでドロップダウンメニューを実装(軽い!)

ドロップダウンメニューをcssだけで実装できる方法があるらしい。 jsファイルの読み込みがないなら軽くていいなぁと思いやってみた。 まずはhtml 一般的な入れ子構造のリストです。 <heade ...