• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
00fairy00の学习园地
博客园    首页    新随笔    联系   管理    订阅  订阅
NO.20 css的clip属性

clip属性我在之前还没有怎么用过,今天学习了一下,发现应该还是一个比较有用的,而且所有的主流浏览器都可兼容!~~

用clip属性来裁剪图片十分的简单。

代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>clip样式</title>
<style>
body
{
    background
:#FFC;
    color
:#F00;
}
.box
{
    position
:relative;
    width
:270px;
    height
:310px;
    float
:left;
    padding-left
:50px;
}
.img
{
    position
:absolute;
    clip
:rect(155px 420px 475px 170px);
    margin-left
:-170px;
    margin-top
:-155px;
}
    
</style>
</head>

<body>
<div style="float:left">原图:<img src="b_1258684795515.jpg" style="vertical-align:top;" /></div>
<div class="box">
    clip:
<img src="b_1258684795515.jpg" class="img" />
</div>
</body>
</html>

 

这是我用clip属性裁切的一张图片,有原图和裁切后的图片!~~

posted on 2009-12-07 14:32  00fairy00  阅读(241)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3