css - 带有圆形背景的 Outlook 圆形图像
问题描述
我正在尝试开发一个电子邮件模板。我需要在前景中具有圆形背景的圆形图像。这是代码和Outlook 输出,这不是我想要开发的。
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div>
<!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://example.com" style="height:80px;v-text-anchor:middle;width:80px;" arcsize="50%" strokecolor="#EB7035" fillcolor="#EB7035">
<w:anchorlock/>
<center style="color:#ffffff;font-family:Helvetica, Arial,sans-serif;font-size:16px;">
<img style="width: 80px;height: 80px;border-radius: 50%; background-color: #e0f6fc;" width="80px" height="80px" align="center" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR13vYIvuNYydJxdMvpmCPXyqzDeUcJIxvdJV1T2GT9FgMyTTiGhw">
</center>
</v:roundrect>
<![endif]-->
<!--[if mso]>
<img style="width: 80px;height: 80px;border-radius: 50%; background-color: #e0f6fc;" width="80px" height="80px" align="center" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR13vYIvuNYydJxdMvpmCPXyqzDeUcJIxvdJV1T2GT9FgMyTTiGhw">
<![endif]-->
</div>
</td>
</tr>
</table>
</body>
</html>
我真正想要的是一个带有边框的简单圆形框,里面有一个简单的圆形图像(框的中心)。有任何想法吗 ?
解决方案
一种解决方案是将您的图像包装在一个 div 中,以将图像裁剪成一个带有border-radius: 50%
和的圆圈overflow: hidden
。然后将该 div 包装在另一个 div 中以创建圆形背景颜色。这是一些入门 HTML 和 CSS,您可以根据自己的喜好调整颜色、填充和边框半径。
HTML
<div class="img-container">
<div class="img_crop">
<img src="your-image" alt="Logo">
</div>
</div>
CSS
.img-container {
width: 300px;
padding: 40px;
background-color: blue;
border-radius: 130px;
}
.img_crop {
border-radius: 50%;
overflow: hidden;
}
img {
width: 100%;
}
推荐阅读
- reactjs - 通过点击游戏学习反应,onClick 不会触发。我想我只是在传递一个 *称为* onClick 的道具
- graph - 如何导出/存储图中的所有路径
- javascript - Webpack 在构建时为 node_modules 解析不正确的文件路径
- python - 在 if 语句中检测到 Python 语法错误
- reactjs - useMutation 错误解析为未处理的拒绝(错误)页面
- font-face - 为什么这个 @import 规则对这个 Web 组件没有任何影响?
- sql - 为什么我在 Access 中的 SQL 语句中将“CF”添加到搜索字符串的末尾时出现“数据类型不匹配”错误?
- ruby-on-rails - 检查 ruby 类是否在特定模块中
- javascript - JavaScript 按钮在某一部分不起作用
- python - 基于列和行输出到 bool 的 Pandas 条件(替换“for”语句)