HTML – 边界崩溃有什么区别:崩溃;和边界间距:0;

前端之家收集整理的这篇文章主要介绍了HTML – 边界崩溃有什么区别:崩溃;和边界间距:0;前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

border-collapse:collapse; 

border-spacing: 0px;   /* only active/useful with option "separate" */
border-collapse:separate; 

相同?

最佳答案
它们是不同的! (请参阅下面的代码段确认).

根据MDN herehere

The border-collapse CSS property determines whether a table’s borders
are separated or collapsed. In the separated model,adjacent cells
each have their own distinct borders. In the collapsed model,adjacent
table cells share borders.

The border-spacing CSS property specifies the distance between the
borders of adjacent table cells (only for the separated borders
model). This is equivalent to the cellspacing attribute in
presentational HTML,but an optional second value can be used to set
different horizontal and vertical spacing.

The border-spacing value is also used along the outside edge of the
table,where the distance between the table’s border and the cells in
the first/last column or row is the sum of the relevant (horizontal or
vertical) border-spacing and the relevant (top,right,bottom,or
left) padding on the table.

This property applies only when border-collapse is separate.

所以这里是一个SNIPPET,有几个例子

body {
  margin: 0;
  font-family: Arial;
}
table {
  width: 100%;
  margin:30px 0
}
td {
  border: 1px solid red
}
.collapse {
  border-collapse: collapse;
}
.separate {
  border-collapse: separate;
}
.no-spacing {
  border-spacing: 0
}
.spacing {
  border-spacing: 10px
}
原文链接:https://www.f2er.com/html/426237.html

猜你在找的HTML相关文章