How TO - 推荐语
了解如何使用 CSS 创建响应式推荐语。
推荐语通常用于让人们了解其他人对您或您的产品的看法。

克里斯·福克斯。 Mighty Schools 首席执行官。
约翰·多伊把我们从一场网络灾难中拯救出来。

丽贝卡·弗莱克斯。 公司首席执行官。
没有人比约翰·多伊更好。

朱莉娅·罗伯茨。 演员。
就是喜欢约翰尼小子。
如何为推荐语添加样式
步骤 1) 添加 HTML
示例
<div class="container">
<img src="bandmember.jpg" alt="头像" style="width:90px">
<p><span>克里斯·福克斯。</span> Mighty Schools 首席执行官。</p>
<p>约翰·多伊把我们从一场网络灾难中拯救出来。</p>
</div>
<div class="container">
<img src="avatar_g2.jpg" alt="头像" style="width:90px">
<p><span >丽贝卡·弗莱克斯。</span> 公司首席执行官。</p>
<p>没有人比约翰·多伊更好。</p>
</div>
步骤 2) 添加 CSS
示例
/* 用圆角边框、灰色背景以及一些内边距和外边距为容器添加样式 */
.container {
border: 2px solid #ccc;
background-color: #eee;
border-radius: 5px;
padding: 16px;
margin: 16px 0;
}
/* 容器后清除浮动 */
.container::after {
content: "";
clear: both;
display: table;
}
/* 将容器内的图像向左浮动。添加右外边距,并将图像样式设置为圆形 */
.container img {
float: left;
margin-right: 20px;
border-radius: 50%;
}
/* 增加 span 元素的字体大小 */
.container span {
font-size: 20px;
margin-right: 15px;
}
/* 为响应式设计添加媒体查询。这将使容器内的文本和图像都居中 */
@media (max-width: 500px) {
.container {
text-align: center;
}
.container img {
margin: auto;
float: none;
display: block;
}
}
自己动手试一试 »