<h2 class="title">這是一個標題</h2>
.title {
  position: relative;
  padding-bottom: 10px;
  text-align: center;
}

.title::after {
  content: "";
  position: absolute;
  left: 50%; /* 從中央開始 */
  bottom: 0;
  transform: translateX(-50%); /* 將底線居中對齊 */
  width: 60px; /* 固定底線的寬度 */
  height: 3px;
  background-color: #000;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.