如何創建:客戶評價

了解如何使用 CSS 創建響應式客戶評價。

客戶評價通常用于讓人們知道其他人對你或你的產品的看法。

Avatar

Chris Fox. CEO at Mighty Schools.

John Doe saved us from a web disaster.

Avatar

Rebecca Flex. CEO at Company.

No one is better than John Doe.

Avatar

Julia Roberts. Actor.

Simply love Johnny Boy.

親自試一試

如何設置客戶評價的樣式

第一步 - 添加 HTML:

<div class="container">
  <img src="bandmember.jpg" alt="Avatar" style="width:90px">
  <p><span>Chris Fox.</span> CEO at Mighty Schools.</p>
  <p>Bill Gates saved us from a web disaster.</p>
</div>
<div class="container">
  <img src="avatar_g2.jpg" alt="Avatar" style="width:90px">
  <p><span>Rebecca Flex.</span> CEO at Company.</p>
  <p>No one is better than Bill Gates.</p>
</div>

第二步 - 添加 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;
  }
}

親自試一試