CSS Links & Tables

CSS超链接与表格样式详解
本文深入探讨了CSS超链接的四种状态样式化及应用,同时详细解析了表格的边框、对齐、内边距和标题设置,提供个性化链接和表格样式的实践指南。

Link

Links can be styled differently depending on what state they are in.

CSS超链接除了可以设定基本的性质,如:颜色、背景色,还可以根据他们所处的状态来样式化。

四种链接状态分别是:

  • a:link - a normal, unvisited link 还没有访问
  • a:visited - a link the user has visited
  • a:hover - a link when the user mouses over it 鼠标划过
  • a:active - a link the moment it is clicked 鼠标点击

order rules: 需遵守的顺序规则

  • a:hover MUST come after a:link and a:visited
  • a:active MUST come after a:hover
Tips:个性化link简单做法,当鼠标划过link时, 改变字体大小 font-size、字体系统 font-family、背景颜色 background-color

Table

Table Border

Note: Both the <table> and the <th> / <td> elements have separate borders.

给表格设置边框的时候,注意表格和单元格都有独立的边框。

The border-collapse property sets whether the table borders are collapsed into a single border or separated.

该性质指定是否合并表格和单元格的边框。合并,如下例:

table
{
border-collapse:collapse;
}
table, td, th
{
border:1px solid black;
}

Table Text Alignment

The text-align property sets the horizontal alignment, like leftright, or center

该性质设定表格中文本的水平对齐方式。

By default, the text in <th> elements are center-aligned and the text in <td> elements are left-aligned.

默认地,表头元素是中心对齐,单元格里的元素为左对齐


The vertical-align property sets the vertical alignment, like top, bottom, or middle

该性质设定表格中文本的垂直对齐方式。

By default, the vertical alignment of text in a table is middle (for both <th> and <td> elements).

默认地,表格中文本是垂直居中对齐

Table Padding

使用padding在 和 元素上设定单元格里内边距。

Caption Side

Specify the placement of a table caption,指定表格标题的位置。

取值:

  • top 默认值,在表格上方,水平居中
  • bottom

Note:IE8 supports the caption-side property only if a !DOCTYPE is specified.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值