DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> CSS詳解
用 CSS 去除 hr 水平線預設的陰影效果
編輯:CSS詳解     

HTML 中的 hr 水平線預設帶有一種立體的陰影觀感,這是由於它的上下邊框顏色不同造成的。想去掉這層陰影其實很簡單。

陰影從哪來

hr 預設高度約為 2px,其中 border-top 為 1px、顏色偏黑,border-bottom 為 1px、顏色偏灰。兩種深淺不同的線條疊在一起,看起來就像有陰影。

解決方法

只要在 CSS 裡把 border-bottom 或 border-top 其中一個設為 none,陰影感就消失了。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Demo</title>
<style type="text/css">
.hrtest {
  height: 20px;
  width: 50px;
  border-top: 1px solid red;
  border-left: none;
  border-right: none;
  border-bottom: none;
}
</style>
</head>
<body>
<hr class="hrtest">
</body>
</html>

這樣一來,水平線就只剩下一條乾淨的實線,能更好地融入現代化的介面設計中。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved