如何创建:标签

学习如何使用 CSS 设置标签样式。

成功 信息 警告 危险 其他

亲自试一试

如何设置标签样式

第一步 - 添加 HTML:

<span class="label success">Success</span>
<span class="label info">Info</span>
<span class="label warning">Warning</span>
<span class="label danger">Danger</span>
<span class="label other">Other</span>

第二步 - 添加 CSS:

.label {
  color: white;
  padding: 8px;
}

.success {background-color: #04AA6D;} /* 绿色 */
.info {background-color: #2196F3;} /* 蓝色 */
.warning {background-color: #ff9800;} /* 橙色 */
.danger {background-color: #f44336;} /* 红色 */
.other {background-color: #e7e7e7; color: black;} /* 灰色 */

亲自试一试