- CSS 教程
- CSS - 首頁
- CSS - 路線圖
- CSS - 簡介
- CSS - 語法
- CSS - 選擇器
- CSS - 包含
- CSS - 測量單位
- CSS - 顏色
- CSS - 背景
- CSS - 字型
- CSS - 文字
- CSS - 圖片
- CSS - 連結
- CSS - 表格
- CSS - 邊框
- CSS - 塊級邊框
- CSS - 內聯邊框
- CSS - 外邊距
- CSS - 列表
- CSS - 內邊距
- CSS - 游標
- CSS - 輪廓
- CSS - 尺寸
- CSS - 捲軸
- CSS - 塊內元素
- CSS - 下拉選單
- CSS - 可見性
- CSS - 溢位
- CSS - 清除浮動
- CSS - 浮動
- CSS - 箭頭
- CSS - 可調整大小
- CSS - 引號
- CSS - 順序
- CSS - 定位
- CSS - 連字元
- CSS - 懸停
- CSS - 顯示
- CSS - 聚焦
- CSS - 縮放
- CSS - 位移
- CSS - 高度
- CSS - 連字元字元
- CSS - 寬度
- CSS - 不透明度
- CSS - Z-Index
- CSS - 底部
- CSS - 導航欄
- CSS - 覆蓋層
- CSS - 表單
- CSS - 對齊
- CSS - 圖示
- CSS - 圖片庫
- CSS - 註釋
- CSS - 載入器
- CSS - 屬性選擇器
- CSS - 組合器
- CSS - 根元素
- CSS - 盒模型
- CSS - 計數器
- CSS - 剪裁
- CSS - 書寫模式
- CSS - Unicode-bidi
- CSS - min-content
- CSS - all
- CSS - inset
- CSS - isolation
- CSS - overscroll
- CSS - justify-items
- CSS - justify-self
- CSS - tab-size
- CSS - pointer-events
- CSS - place-content
- CSS - place-items
- CSS - place-self
- CSS - max-block-size
- CSS - min-block-size
- CSS - mix-blend-mode
- CSS - max-inline-size
- CSS - min-inline-size
- CSS - offset
- CSS - accent-color
- CSS - user-select
- CSS 高階
- CSS - 網格
- CSS - 網格佈局
- CSS - Flexbox
- CSS - 可見性
- CSS - 定位
- CSS - 層
- CSS - 偽類
- CSS - 偽元素
- CSS - @規則
- CSS - 文字效果
- CSS - 分頁媒體
- CSS - 列印
- CSS - 佈局
- CSS - 驗證
- CSS - 圖片精靈
- CSS - !important
- CSS - 資料型別
- CSS3 教程
- CSS3 - 教程
- CSS - 圓角
- CSS - 邊框圖片
- CSS - 多重背景
- CSS - 顏色
- CSS - 漸變
- CSS - 盒陰影
- CSS - 盒裝飾中斷
- CSS - 游標顏色
- CSS - 文字陰影
- CSS - 文字
- CSS - 2D 變換
- CSS - 3D 變換
- CSS - 過渡
- CSS - 動畫
- CSS - 多列
- CSS - 盒尺寸
- CSS - 工具提示
- CSS - 按鈕
- CSS - 分頁
- CSS - 變數
- CSS - 媒體查詢
- CSS - 函式
- CSS - 數學函式
- CSS - 遮罩
- CSS - 形狀
- CSS - 樣式圖片
- CSS - 特效性
- CSS - 自定義屬性
- CSS 響應式
- CSS RWD - 簡介
- CSS RWD - 視口
- CSS RWD - 網格檢視
- CSS RWD - 媒體查詢
- CSS RWD - 圖片
- CSS RWD - 影片
- CSS RWD - 框架
- CSS 工具
- CSS - PX 到 EM 轉換器
- CSS - 顏色選擇器和動畫
- CSS 資源
- CSS - 有用資源
- CSS - 討論
CSS - clip 屬性
CSS 的 clip 屬性用於為元素建立剪裁區域,該區域定義元素的可見區域。只有指定的區域可見,其他區域將被隱藏。clip 屬性僅適用於具有絕對或固定定位的元素。
語法
clip: auto | shape | initial | inherit;
屬性值
| 值 | 描述 |
|---|---|
| auto | 不會對元素應用剪裁。預設值。 |
| shape | 它剪裁元素。唯一可能的值是 rect(top, right, bottom, left)。 |
| initial | 它將屬性設定為其預設值。 |
| inherit | 它從父元素繼承屬性。 |
CSS clip 屬性示例
以下示例說明了具有不同值的 clip 屬性。
帶有 auto 值的 clip 屬性
為了不對絕對或固定定位的元素進行剪裁,以便整個元素可見,我們使用 clip 屬性的 auto 值。這在以下示例中顯示。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.sample {
width: 200px;
background-color: lightblue;
padding: 10px;
}
.clip-rect {
position: absolute;
width: 200px;
background-color: lightblue;
padding: 10px;
clip: auto;
}
</style>
</head>
<body>
<h2>
CSS clip property
</h2>
<p>
Original text:
</p>
<div class="sample">
TutorialsPoint is an educational platform offering
a vast array of tutorials and resources across various
subjects, including programming, web development, and
technology. It aims to provide accessible and
comprehensive learning materials for learners
of all levels globally.
</div>
<br/>
<p>
Clip: auto value
</p>
<div class="clip-rect">
TutorialsPoint is an educational platform offering
a vast array of tutorials and resources across various
subjects, including programming, web development,
and technology. It aims to provide accessible and
comprehensive learning materials for learners of
all levels globally.
</div>
<br/>
</body>
</html>
帶有 rect() 值的 clip 屬性
為了剪裁絕對或固定定位元素的一部分,以便只有指定的區域可見,而其餘區域不可見,我們使用 clip 屬性的 rect(top, right, bottom, left) 值。指定的值將從頂部和左側邊緣剪裁元素。這在以下示例中顯示。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.sample {
width: 200px;
background-color: lightgreen;
padding: 10px;
}
.clip-rect {
position: absolute;
width: 200px;
background-color: lightgreen;
padding: 10px;
clip: rect(0px 170px 140px 0px);
}
</style>
</head>
<body>
<h2>
CSS clip property
</h2>
<p>
Original text:
</p>
<div class="sample">
TutorialsPoint is an educational platform offering
a vast array of tutorials and resources across various
subjects, including programming, web development,
and technology. It aims to provide accessible and
comprehensive learning materials for learners
of all levels globally.
</div>
<br/>
<p>
Clip: rect(0px 170px 140px 0px) value
</p>
<div class="clip-rect">
TutorialsPoint is an educational platform
offering a vast array of tutorials and resources
across various subjects, including programming,
web development, and technology. It aims to provide
accessible and comprehensive learning materials
for learners of all levels globally.
</div>
<br/>
</body>
</html>
帶有圖片的 clip 屬性
clip 屬性也可以與絕對或固定定位的圖片一起使用。在以下示例中,auto 和 rect(top, right, bottom, left) 值已與圖片一起使用。
示例
<!DOCTYPE html>
<html>
<head>
<style>
img {
width: 300px;
height: 200px;
}
.clip-auto {
position: absolute;
clip: auto;
}
.clip-rect {
position: absolute;
clip: rect(0px 140px 170px 0px);
}
</style>
</head>
<body>
<h2>
CSS clip property</h2>
<p>Original image:</p>
<img src="/css/images/white-flower.jpg"
/>
<p>
clip: auto value
</p>
<img src="/css/images/white-flower.jpg"
/>
<p>
clip: rect(0px 140px 170px 0px) value
</p>
<img src="/css/images/white-flower.jpg" class="clip-rect"
/>
</body>
</html>
注意
- clip 屬性已被棄用,並由 clip-path 屬性替換
- 如果 'overflow: visible',clip 屬性將不起作用。
支援的瀏覽器
| 屬性 | ![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| clip | 1.0 | 8.0 | 1.0 | 1.0 | 7.0 |
css_properties_reference.htm
廣告




