正确使用表格
仅用于表格的 HTML 标签:
<table>
<caption>
<colgroup>
<col>
<thead>
<tbody>
<tr>
<th>
<td>
|
|
表格样式
添加留白
|
|
横向、竖向对齐
|
|
表格边框
对table 使用border, 只影响table最外面的border;
对td, th使用border, 会产生可见的cells间的空隙.
单元格间的空隙
123table {border-spacing: 0;}消除双边框
123table {border-collapse: collapse | separate(D);}圆角
12345td {border: 1px solid black;/* 如果设置了border-collapse, radius将被忽略. */border-radius: 5px;}
行、列的样式
|
|
HTML用<colgroup>
, <col>
来为列分组. 可以用它们来(类选择器)来style列.
|
|
Note: 通常浏览器会显示空cell的border和background color.
如果想hide它们,table { empty-cells: hide; }
但border-collapse: collapse;
会使其无效.
表单样式
HTML表单元素
- Fieldset -
<fieldset>
- Legend -
<legend>
Fieldset 的标题 - Text field -
<input type="text | password | textarea">
- Button -
<input type="submit | button">
- Drop-down menu -
<select>
- Checkbox / radio -
<input type="checkbox | radio">
CSS布局表单
- Wrap each label in a tag
对 radio,<span class="label">What's your favorite color?</span>
其他,<label>Label</label><input =type="text" />
Set the display property to
inline-block
, and set a width1234.label {display: inline-block;width: 20em;}Adjust the style
1234567.label {float: left;width: 20em;vertical-align: top;text-align: right;margin-right: 15px;}
伪类和表单
:focus, :ckecked, :enabled :disabled