height 和 line-height 之間有什麼區別?
height 是容器的縱向度量,例如 div 的 height。
line-height 是 CSS 屬性,用於指定行高,即第一行文字的頂部到第二行文字頂部的距離。它是兩個段落之間的行距。
例
你可以嘗試執行以下程式碼以瞭解 height 和 line-height 之間的區別
<!DOCTYPE html>
<html>
<head>
<style>
.height {
height: 20px;
}
.lheight {
line-height: 15px;
}
.lheightbigger {
line-height: 35px;
}
</style>
</head>
<body>
<h2>Height</h2>
<div class="height">
This is demo text. This is demo text.
This is demo text. This is demo text.
This is demo text. This is demo text.
</div>
<h2>Line Height with less space</h2>
<div class="lheight">
This is demo text showing line height example. This is demo text showing line height example.
This is demo text showing line height example. This is demo text showing line height example.
This is demo text showing line height example.This is demo text showing line height example.
</div>
<h2>Normal Text</h2>
<div>
This is normal text.
This is normal text.
This is normal text.
</div>
<h2>Line Height with more space</h2>
<div class="lheightbigger">
This is normal text. This is normal text.This is normal text.
This is normal text. This is normal text.This is normal text.
This is normal text. This is normal text.This is normal text.
</div>
</body>
</html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP