当前位置: 首页 > news >正文

专业商城网站搭建价格外贸推广渠道有哪些

专业商城网站搭建价格,外贸推广渠道有哪些,做网站用哪个电脑,广告设计公司宣传文案CSS 样式化表格:从基础到高级技巧 1. 典型的 HTML 表格结构2. 为表格添加样式2.1 间距和布局2.2 简单的排版2.3 图形和颜色2.4 斑马条纹2.5 样式化标题 3. 完整的示例代码4. 总结 在网页设计中,表格是展示数据的常见方式。然而,默认的表格样式…

CSS 样式化表格:从基础到高级技巧

    • 1. 典型的 HTML 表格结构
    • 2. 为表格添加样式
      • 2.1 间距和布局
      • 2.2 简单的排版
      • 2.3 图形和颜色
      • 2.4 斑马条纹
      • 2.5 样式化标题
    • 3. 完整的示例代码
    • 4. 总结

在网页设计中,表格是展示数据的常见方式。然而,默认的表格样式通常显得单调且难以阅读。本文将详细介绍如何使用 CSS 为 HTML 表格添加样式,使其更加美观和易于理解。我们将通过一个完整的示例代码,逐步优化表格的外观。

1. 典型的 HTML 表格结构

让我们从一个典型的 HTML 表格开始。以下是一个展示英国著名朋克乐队信息的表格:

<table><caption>A summary of the UK's most famous punk bands</caption><thead><tr><th scope="col">Band</th><th scope="col">Year formed</th><th scope="col">No. of Albums</th><th scope="col">Most famous song</th></tr></thead><tbody><tr><th scope="row">Buzzcocks</th><td>1976</td><td>9</td><td>Ever fallen in love (with someone you shouldn't've)</td></tr><tr><th scope="row">The Clash</th><td>1976</td><td>6</td><td>London Calling</td></tr><tr><th scope="row">The Stranglers</th><td>1974</td><td>17</td><td>No More Heroes</td></tr></tbody><tfoot><tr><th scope="row" colspan="2">Total albums</th><td colspan="2">77</td></tr></tfoot>
</table>

2. 为表格添加样式

2.1 间距和布局

首先,我们需要调整表格的间距和布局,使其更加清晰。我们将使用 table-layout: fixedborder-collapse: collapse 来控制表格的布局和边框。

/* 间距 */
table {table-layout: fixed;width: 100%;border-collapse: collapse;border: 3px solid purple;
}thead th:nth-child(1) {width: 30%;
}thead th:nth-child(2) {width: 20%;
}thead th:nth-child(3) {width: 15%;
}thead th:nth-child(4) {width: 35%;
}th,
td {padding: 20px;
}

2.2 简单的排版

接下来,我们为表格添加一些简单的排版样式,以提高可读性。

/* 排版 */
html {font-family: "helvetica neue", helvetica, arial, sans-serif;
}thead th,
tfoot th {font-family: "Rock Salt", cursive;
}th {letter-spacing: 2px;
}td {letter-spacing: 1px;
}tbody td {text-align: center;
}tfoot th {text-align: right;
}

2.3 图形和颜色

为了让表格更具视觉吸引力,我们可以为表头和表尾添加背景图像和颜色。

/* 图形和颜色 */
thead,
tfoot {background: url(leopardskin.jpg);color: white;text-shadow: 1px 1px 1px black;
}thead th,
tfoot th,
tfoot td {background: linear-gradient(to bottom, rgb(0 0 0 / 10%), rgb(0 0 0 / 50%));border: 3px solid purple;
}

2.4 斑马条纹

为了增强表格的可读性,我们可以为表格的行添加斑马条纹效果。

/* 斑马条纹 */
tbody tr:nth-child(odd) {background-color: #ff33cc;
}tbody tr:nth-child(even) {background-color: #e495e4;
}tbody tr {background-image: url(noise.png);
}table {background-color: #ff33cc;
}

2.5 样式化标题

最后,我们为表格的标题添加样式,使其更加突出。

/* 标题 */
caption {font-family: "Rock Salt", cursive;padding: 20px;font-style: italic;caption-side: bottom;color: #666;text-align: right;letter-spacing: 1px;
}

3. 完整的示例代码

以下是完整的 HTML 和 CSS 代码,展示了如何样式化一个表格:

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>样式化表格示例</title><link href="https://fonts.googleapis.com/css?family=Rock+Salt" rel="stylesheet" type="text/css"><style>/* 间距 */table {table-layout: fixed;width: 100%;border-collapse: collapse;border: 3px solid purple;}thead th:nth-child(1) {width: 30%;}thead th:nth-child(2) {width: 20%;}thead th:nth-child(3) {width: 15%;}thead th:nth-child(4) {width: 35%;}th,td {padding: 20px;}/* 排版 */html {font-family: "helvetica neue", helvetica, arial, sans-serif;}thead th,tfoot th {font-family: "Rock Salt", cursive;}th {letter-spacing: 2px;}td {letter-spacing: 1px;}tbody td {text-align: center;}tfoot th {text-align: right;}/* 图形和颜色 */thead,tfoot {background: url(leopardskin.jpg);color: white;text-shadow: 1px 1px 1px black;}thead th,tfoot th,tfoot td {background: linear-gradient(to bottom, rgb(0 0 0 / 10%), rgb(0 0 0 / 50%));border: 3px solid purple;}/* 斑马条纹 */tbody tr:nth-child(odd) {background-color: #ff33cc;}tbody tr:nth-child(even) {background-color: #e495e4;}tbody tr {background-image: url(noise.png);}table {background-color: #ff33cc;}/* 标题 */caption {font-family: "Rock Salt", cursive;padding: 20px;font-style: italic;caption-side: bottom;color: #666;text-align: right;letter-spacing: 1px;}</style>
</head>
<body><table><caption>A summary of the UK's most famous punk bands</caption><thead><tr><th scope="col">Band</th><th scope="col">Year formed</th><th scope="col">No. of Albums</th><th scope="col">Most famous song</th></tr></thead><tbody><tr><th scope="row">Buzzcocks</th><td>1976</td><td>9</td><td>Ever fallen in love (with someone you shouldn't've)</td></tr><tr><th scope="row">The Clash</th><td>1976</td><td>6</td><td>London Calling</td></tr><tr><th scope="row">The Stranglers</th><td>1974</td><td>17</td><td>No More Heroes</td></tr></tbody><tfoot><tr><th scope="row" colspan="2">Total albums</th><td colspan="2">77</td></tr></tfoot></table>
</body>
</html>

4. 总结

通过本文的学习,你应该已经掌握了如何使用 CSS 为 HTML 表格添加样式。从调整间距和布局到添加斑马条纹和背景图像,CSS 提供了丰富的工具来美化表格。

http://www.fp688.cn/news/160499.html

相关文章:

  • 微信导航网站有用吗自媒体论坛交流推荐
  • 做网站的公司哪些靠谱2345浏览器网页版
  • flash网站源码模板网页模板代码
  • 中国化学工程第六建设有限公司seo免费课程视频
  • 做网站买什么服务器 便宜百度指数1000搜索量有多少
  • 怎样在网站上做友情链接网推公司干什么的
  • 个人可以建论坛网站吗市场推广
  • 网站制作视频教程下载百度云广州网络推广公司
  • 县门户网站建设整改免费建自己的网址
  • 外贸免费建设网站百度百家官网入口
  • html网站模板免费下载最近热点新闻事件
  • 五月天乐队做网站网络营销的特征和功能
  • 建设银行网站 开户行怎么查软文代发平台
  • h5做网站用什么框架百度关键字优化价格
  • 忻州政府网站建设软文写作的三个要素
  • 网站运营介绍百度关键词推广方案
  • 网站访问大小seo管理系统
  • 做互联网产品和运营必备的网站网站建设深圳公司
  • 深圳高端网站建设创新推一手新闻发稿平台
  • 做网站要执照吗百度竞价恶意点击软件
  • 邯郸做网站网站注册流程和费用
  • 蚌埠网站建设哪家好网站seo软件
  • 上街区做网站推客平台
  • 有没有做ppt好看的免费网站想做电商应该怎么入门
  • 下载网站模板怎么使用企业关键词推广
  • 新市网站建设关键词在线听免费
  • 制作二维码的软件百度seo效果怎么样
  • 经营网站备案信息陕西seo优化
  • 自己制作网站做外贸赚钱吗下载浏览器
  • 网站导航图怎么做人工智能培训机构排名