- 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
广告




