HTML表格中的对角线 - 电子邮件签名

时间:2015-07-02 15:23:22

标签: css html-email

我需要在HTML签名中使用表格布局,但需要对角线。我知道这需要内联CSS,但有一个选项可以使用内联伪元素吗?

我在表格中有对角线的示例 - 但不确定如何将其合并到HTML电子邮件签名中。

有什么想法吗?



* {
	margin: 0;
	padding: 0;
}
body {
  background: #FFF;
}
table {
  border-collapse: collapse;
  margin: 50px 0 0 50px;
  border-top: solid 1px #000;
  position: relative;
}

/* Very top border */
table:before {
  content: '';
  display: block;
  position: absolute;
  top: -20px;
  left: 120px;
  height: 20px;
  width: 240px;
  border: solid 1px #000;
  border-bottom: none;
}

/* Far right headers top border (it's outside the table) */
table:after { 
  content: '';
  display: block;
  position: absolute;
  border-top: solid 1px #000;
  width: 101px;
  right: -101px;
  top: 0;
}

/* 
 - Apply header background/font colour 
 - Set base z-index for IE 9 - 10
*/
thead, th:before {
  background: #03a9f4;
  color: #FFF;
  z-index: 1;
}

/* min-width and max-width together act like a width */
th {
	min-width: 60px;
	max-width: 60px;
	position: relative;
	height: 100px;
}

/* Pseudo element borders */
th:before {
	content: '';
	display: block;
	position: absolute;
    top: 0;
    right: -50px;
	height: 100px;
	width: 60px;
	border: solid 1px #000;
	border-right: none;
    border-top: none;
	transform: skew(-45deg);
    border-bottom: none;
}

/* Apply the right border only to the last pseudo element */
thead th:last-child:before {
	border-right: solid 1px #000;
}

/* Apply the top border only to the first rows cells */
tbody tr:first-child td {
  border-top: solid 1px #000;
}

/* 
 - Rotate and position headings
 - Padding centers the text vertically and does the job of height
 - z-index ensures that the text appears over the background color in IE 9 - 10
*/
th span {
transform: rotate(-45deg);
  display: inline-block;
  vertical-align: middle;
  position: absolute;
  right: -70px;
  bottom: 29px;
  height: 0;
  padding: 0.75em 0 1.85em;
  width: 100px;
  z-index: 2;
}


/* Create first two th styles */
th:nth-child(1),th:nth-child(2)  {
  border: solid 1px #000;
  border-top: none;
  border-bottom: none;
}
th:nth-child(2) {
	border-right: none;
}
th:nth-child(1):before,
th:nth-child(2):before  {
	display: none;	
}

td {
	border: solid 1px #000;
	border-bottom: none;
	border-top: none;
	height: 20px;
	text-align: center;
}

tfoot { 
	border: solid 1px #000;
}

<!DOCTYPE html>
<html>
<head>
<meta name="description" content="" />
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <table>
		<thead>
			<tr>
			  <th>One</th>
			  <th>Two</th>
              <th><span>Three</span></th>
			  <th><span>Four</span></th>
              <th><span>Five</span></th>
              <th><span>Six</span></th>
              <th><span>Seven</span></th>
			</tr>
		</thead>
		<tbody>
			<tr>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
              <td>0</td>
              <td>0</td>
              <td>0</td>
			</tr>
			<tr>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
              <td>0</td>
              <td>0</td>
              <td>0</td>
			</tr>
          <tr>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
              <td>0</td>
              <td>0</td>
              <td>0</td>
			</tr>
          <tr>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
              <td>0</td>
              <td>0</td>
              <td>0</td>
			</tr>
          <tr>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
              <td>0</td>
              <td>0</td>
              <td>0</td>
			</tr>
          <tr>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
              <td>0</td>
              <td>0</td>
              <td>0</td>
			</tr>
          <tr>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
              <td>0</td>
              <td>0</td>
              <td>0</td>
			</tr>
			
		</tbody>
		<tfoot>
			<tr>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
			  <td>0</td>
              <td>0</td>
              <td>0</td>
              <td>0</td>
			</tr>
		</tfoot>
	</table>
</body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

  

是否可以选择使用内联伪元素

没有。内联样式属性可以将CSS应用于给定元素。它们完全取代选择器。