萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> 腳本程式專題 >> JavaScript

jQuery Corner 外掛實現圓角邊框(舊版 IE 相容方案)

在 CSS3 border-radius 普及前,jQuery Corner 外掛透過動態生成多層 <div> 模擬圓角。本文示範基本用法,並指出背景顏色在 IE 下渲染異常的已知問題。

使用步驟

  1. 引入 jQuery 與 jquery.corners.min.js。
  2. 目標元素加上類別(如 .roundedd)。
  3. 呼叫 $('.roundedd').corners()。

完整範例

<!DOCTYPE html>
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title>jQuery Corners</title>
<script src="jquery.js"></script>
<script src="jquery.corners.min.js"></script>
<script>$(function(){ $('.roundedd').corners(); });</script>
<style>
.roundedd { background-color:#eeeeee; padding:20px; }
</style>
</head>
<body>
<div class="roundedd">class="rounded {10px}"</div>
</body>
</html>

已知 Bug

若 background-color 使用關鍵字(red、yellow)在 IE 下圓角不顯示;建議改用十六進位(#ff0000、#ffff00)或 RGB 表示法。

現代標準:CSS3 border-radius

.roundedd { border-radius: 10px; background:#eee; }

所有現代瀏覽器(含 IE9+)完整支援,無需任何 JS 库,效能極佳。

copyright © 萬盛學電腦網 all rights reserved