在图像右侧居中放置两行文本
Center two text lines right of image
我正在尝试对齐图像中心旁边的两个文本行。我试过 "vertical-align: middle;"
但它不会像这样将我的文本保留在两行中:
this is what I'm trying to achieve.
我的代码包括:
<p class="address">
<img class="logo" src="source" alt="">
<span class="location">Line 1 of text</span>
<span class="location_2"> Line 2 of text</span>
</p>
使用CSS代码:
p.address{font-family: Helvetica; font-size: 13px; color: #000000; margin-left: 0px;vertical-align:center;}
span.location{display: inline; }
span.location_2{display: block; }
我也试过这个解决方案:http://jsfiddle.net/hiral/bhu4p04r/7/ - 但它显示图片下方的文字。
图像是 34x58px
,我正在尝试为 Outlook html 签名实现此图像。
我打算尝试使用 <div>
容器,将 <img>
放入其中,然后是 <p>
,不知道是否可行。
LGSon 稍作修改后给出肯定结果的答案,示例如下:
<table style="margin-bottom:5px; font-family: Helvetica; font-size: 13px; color: #000000;">
<tr>
<td>
<img style="max-height:52px" src="img_source_here" alt="">
</td>
<td valign="middle" style="font-size:14px; margin-left: 10px;">
Text 1<br>Text 2
</td>
</tr>
</table>
谢谢大家的帮助!
电子邮件通常最好构建为表格,但 CSS 表格可能有效:
img {
min-width: 75px;
height: 90px;
}
.columns {
display: table;
}
.columns div {
display: table-cell;
vertical-align: middle;
padding: 1em;
}
<div class="medium-12 columns">
<div class="imgwrap">
<img src="http://placekitten.com/g/75/90" class="left" />
</div>
<div class="text">1
<br />2
<br />3</div>
</div>
如果您不知道哪些电子邮件客户端会打开您的邮件,我会这样做。
<table style="font-family: Helvetica; font-size: 13px; color: #000000; ">
<tr>
<td rowspan="2">
<img style="border: 3px solid #000" src="http://placehold.it/100" alt="">
</td>
<td valign="bottom">
Line 1 of text
</td>
</tr>
<tr>
<td valign="top">
Line 2 of text
</td>
</tr>
</table>
我正在尝试对齐图像中心旁边的两个文本行。我试过 "vertical-align: middle;"
但它不会像这样将我的文本保留在两行中:
this is what I'm trying to achieve.
我的代码包括:
<p class="address">
<img class="logo" src="source" alt="">
<span class="location">Line 1 of text</span>
<span class="location_2"> Line 2 of text</span>
</p>
使用CSS代码:
p.address{font-family: Helvetica; font-size: 13px; color: #000000; margin-left: 0px;vertical-align:center;}
span.location{display: inline; }
span.location_2{display: block; }
我也试过这个解决方案:http://jsfiddle.net/hiral/bhu4p04r/7/ - 但它显示图片下方的文字。
图像是 34x58px
,我正在尝试为 Outlook html 签名实现此图像。
我打算尝试使用 <div>
容器,将 <img>
放入其中,然后是 <p>
,不知道是否可行。
LGSon 稍作修改后给出肯定结果的答案,示例如下:
<table style="margin-bottom:5px; font-family: Helvetica; font-size: 13px; color: #000000;">
<tr>
<td>
<img style="max-height:52px" src="img_source_here" alt="">
</td>
<td valign="middle" style="font-size:14px; margin-left: 10px;">
Text 1<br>Text 2
</td>
</tr>
</table>
谢谢大家的帮助!
电子邮件通常最好构建为表格,但 CSS 表格可能有效:
img {
min-width: 75px;
height: 90px;
}
.columns {
display: table;
}
.columns div {
display: table-cell;
vertical-align: middle;
padding: 1em;
}
<div class="medium-12 columns">
<div class="imgwrap">
<img src="http://placekitten.com/g/75/90" class="left" />
</div>
<div class="text">1
<br />2
<br />3</div>
</div>
如果您不知道哪些电子邮件客户端会打开您的邮件,我会这样做。
<table style="font-family: Helvetica; font-size: 13px; color: #000000; ">
<tr>
<td rowspan="2">
<img style="border: 3px solid #000" src="http://placehold.it/100" alt="">
</td>
<td valign="bottom">
Line 1 of text
</td>
</tr>
<tr>
<td valign="top">
Line 2 of text
</td>
</tr>
</table>