CSS表格

作者: Yonginggg | 来源:发表于2019-08-20 16:08 被阅读0次

表格

.html

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded md-focus" lang="html" contenteditable="true" cid="n4" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px 0px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<table border="1">
<tr>
<td>name</td>
<td>age</td>
<td>gender</td>
</tr>
<tr>
<td>mike</td>
<td>20</td>
<td>men<CS </tr>
<tr>
<td>tom</td>
<td>15</td>
<td>men</td>
</tr>
<tr>
<td>lorra</td>
<td>25</td>
<td>women</td>
</tr>
</table>
</body>
</html></pre>

image

关键语句<table border="1">,border设置了表格的边框

表格属性

属性 描述
border-collapse 设置是否把表格边框合并为单一的边框。
border-spacing 设置分隔单元格边框的距离。
caption-side 设置表格标题的位置。
empty-cells 设置是否显示表格中的空单元格。
table-layout 设置显示单元、行和列的算法。

折叠边框 border-collapse

描述
separate 默认值。边框会被分开。不会忽略 border-spacing 和 empty-cells 属性。
collapse 如果可能,边框会合并为一个单一的边框。会忽略 border-spacing 和 empty-cells 属性。
inherit 规定应该从父元素继承 border-collapse 属性的值。

为表格设置合并边框模型:

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="" contenteditable="true" cid="n50" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px 0px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> table{
border-collapse: collapse;
}</pre>

image

可以看到边框时一条线而不是上面的两条线

表格宽度和高度 / 表格文本对齐

.css

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="css" contenteditable="true" cid="n56" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px 0px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> td{
width: 200px;
height: 50px;
text-align: center;
}</pre>

[图片上传失败...(image-d9358e-1566288471528)] 表格内边距

.css

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="css" contenteditable="true" cid="n60" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px 0px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> td{
padding:15px;
}
​</pre>

字母头间距缩进

表格颜色

.css

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="css" contenteditable="true" cid="n66" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px 0px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> tr {
background-color: green;
color: white;
}</pre>

image

相关文章

  • CSS初探16

    Head First HTML与CSS 第十一章 布局与定位 CSS——掌控页面的表现 CSS表格显示 CSS表格...

  • css样式——表格篇

    CSS 表格属性可以帮助您极大地改善表格的外观。 表格边框 如需在 CSS 中设置表格边框,请使用border属性...

  • CSS样式

    CSS背景 CSS字体 CSS链接 CSS 列表 CSS 表格 CSS轮廓 CSS背景 1、背景色 ba...

  • CSS学习的一部分内容

    本篇是将CSS中的表格,轮廓,定位,浮动的学习进行的总结。完全个人理解,仅供参考。(耶!!!) CSS表格 CSS...

  • 归零——html、css学习-第三天

    CSS学习-cascading style sheet层叠样式表格 CSS权重 !important ...

  • CSS表格

    表格 表格的作用:用来表示格式化的数据 使用table标签创建一个表格 tr 标签标识表格中的一行(可以编写一个或...

  • css 表格

    表格 表格的作用:用来表示格式化的数据 使用table标签创建一个表格 tr 标签标识表格中的一行(可以编写一个或...

  • CSS表格

    表格采用行列格式的简单结构,以及生活中广泛应用,对于他的理解和代码编写都很方便。表格的每行的列数通常一致,同行单元...

  • CSS表格

    表格是一个矩形网格中的信息安排。表格用来表示一系列信息的关系。 表格结构##### 在表格中,信息显示在一个个的单...

  • css 表格

    表格 表格的作用:用来表示格式化的数据 使用table标签创建一个表格tr 标签标识表格中的一行(可以编写一个或多...

网友评论

    本文标题:CSS表格

    本文链接:https://www.haomeiwen.com/subject/jnvpsctx.html