无法删除 table 中的边框间距
Can't remove border spacing in table
我希望所附示例中的图片和灰色区域粘在一起 和 高度相同 - 但我似乎无法删除正在破坏的边框间距这个。
对我做错了什么有什么想法吗?抱歉样式混乱 sheet。
https://jsfiddle.net/q43L8pqy/1/
PS:我知道这可以通过 div 解决,但这是针对一个非常特殊的环境。
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<style>
body {
background-color: #efefef;
border: 0px;
margin: 0px;
}
h1, h2, h3 {
color: #333333;
margin: 0px;
font-family: Verdana, Helvetica;
}
}
h1 {font-size: 21px;}
h2 {font-size:18px;font-weight:bold;}
h3 a {color: #0269cd; text-decoration: none; text-decoration: none;font-weight:bold;}
table.module{border-spacing:0!important;background-color: #ffffff;border-collapse: collapse;}
h3 {font-size: 16px;font-weight:normal;}
html,body{min-width:600px;}
</style>
</head>
<body style="background-color: #efefef;">
<div style="padding-top:150px;padding-bottom:150px;background-color:white;">
<table width="600" height="242" align="center" border="0" cellspacing="0" cellpadding="0" class="module" >
<tr>
<td width="263" height="242" style="padding-left:30px;"><a href="http://www.cnn.com"> <img src="http://placekitten.com/263/242" width="263" height="242" alt="Module2_img"></a></td>
<td width="277" height="242" align="left" style="padding-left:18px;background-color:#efefef;">
<h2>Content</h2><br>
<h3>There should be a cute cat on the left <br><br>
<a href="http://www.ikea.no/">Click this</a></h3>
</td>
</tr>
</table>
</div>
</body>
</html>
我可以通过改变两件事来解决这个问题。
为了让您的图像贴在列的 right-side 上,您需要将第二个单元格的填充从 18px
增加到 30px
。或者,您可以使每个单元格的宽度相同,然后将图像向右浮动。
要去除图像下方的额外填充,您需要向受影响的图像添加 display: block;
。 <img>
是一个内联元素,因此它会在其下方留出额外的填充空间,以便为文本等其他元素腾出空间。
如果您出于任何原因无法使用 display: block;
,vertical-align: bottom;
也可以。这将允许您保持图像内联,并将设置图像的垂直对齐方式,使其与 table 单元格的底部匹配。
我希望所附示例中的图片和灰色区域粘在一起 和 高度相同 - 但我似乎无法删除正在破坏的边框间距这个。
对我做错了什么有什么想法吗?抱歉样式混乱 sheet。
https://jsfiddle.net/q43L8pqy/1/
PS:我知道这可以通过 div 解决,但这是针对一个非常特殊的环境。
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<style>
body {
background-color: #efefef;
border: 0px;
margin: 0px;
}
h1, h2, h3 {
color: #333333;
margin: 0px;
font-family: Verdana, Helvetica;
}
}
h1 {font-size: 21px;}
h2 {font-size:18px;font-weight:bold;}
h3 a {color: #0269cd; text-decoration: none; text-decoration: none;font-weight:bold;}
table.module{border-spacing:0!important;background-color: #ffffff;border-collapse: collapse;}
h3 {font-size: 16px;font-weight:normal;}
html,body{min-width:600px;}
</style>
</head>
<body style="background-color: #efefef;">
<div style="padding-top:150px;padding-bottom:150px;background-color:white;">
<table width="600" height="242" align="center" border="0" cellspacing="0" cellpadding="0" class="module" >
<tr>
<td width="263" height="242" style="padding-left:30px;"><a href="http://www.cnn.com"> <img src="http://placekitten.com/263/242" width="263" height="242" alt="Module2_img"></a></td>
<td width="277" height="242" align="left" style="padding-left:18px;background-color:#efefef;">
<h2>Content</h2><br>
<h3>There should be a cute cat on the left <br><br>
<a href="http://www.ikea.no/">Click this</a></h3>
</td>
</tr>
</table>
</div>
</body>
</html>
我可以通过改变两件事来解决这个问题。
为了让您的图像贴在列的 right-side 上,您需要将第二个单元格的填充从 18px
增加到 30px
。或者,您可以使每个单元格的宽度相同,然后将图像向右浮动。
要去除图像下方的额外填充,您需要向受影响的图像添加 display: block;
。 <img>
是一个内联元素,因此它会在其下方留出额外的填充空间,以便为文本等其他元素腾出空间。
如果您出于任何原因无法使用 display: block;
,vertical-align: bottom;
也可以。这将允许您保持图像内联,并将设置图像的垂直对齐方式,使其与 table 单元格的底部匹配。