以两个div右上角对齐为例:

效果图:

1.同级定位

<!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>同级</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
}
.main {
position: relative;
width:1000px;
height:600px;
background: gray;
}
.div_01 {
position: absolute;
top: 0;
right: 0;
width: 600px;
height: 400px;
z-index: 1;
background: yellow;
}
.div_02 {
position: absolute;
top: 0;
right: 0;
width: 200px;
height: 100px;
z-index: 2;
background: green;
}
</style>
</head>
<body>
<div class="main">
<div class="div_01">
div_01
</div>
<div class="div_02">
div_02
</div>
</div>
</body>
</html>

2.父子级定位

<!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>嵌套</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
}
.div_01 {
position: relative;
width:600px;
height:400px;
background: yellow;
}
.div_02 {
position:absolute;
top: 0;
right: 0;
width:200px;
height:100px;
background: green;
}
</style>
</head>
<body>
<div class="div_01">
<div class="div_02">
div_02
</div>
</div>
</body>
</html>

最新文章

  1. VIM C++语法高亮配色
  2. css中外边距合并
  3. 《你必须知道的.NET》书中对OCP(开放封闭)原则的阐述
  4. BZOJ3750 : [POI2015]Pieczęć
  5. Nobel Lecture, December 12, 1929 Thermionic phenomena and the laws which govern them
  6. Web Project配置Hirbernate
  7. [leetcode]_Count and Say
  8. c# 4.0新特性一览
  9. [NOI2007]货币兑换Cash(DP+动态凸包)
  10. Cocos2d-x3.0 触摸事件
  11. Spring源码学习-容器BeanFactory(四) BeanDefinition的创建-自定义标签的解析.md
  12. Ethzasl MSF源码阅读(1):程序入口和主题订阅
  13. 聊聊我怎么系统学习Linux技能并快速提高的
  14. for..in 遍历js对象
  15. 【nginx】之proxy_pass
  16. CSS 基础 例子 行高line-height
  17. 第六次作业 orm整合 接口
  18. hexo主题中添加相册功能
  19. 解决Vsphere Client 60天过期问题
  20. HTTP认证机制

热门文章

  1. 如果你觉得我的博客对你有帮助,请帮忙加点我所在团队博客访问量http://home.cnblogs.com/u/newbe/
  2. php中explode与split的区别介绍
  3. 离线安装eclipse的svn插件
  4. 走读openwrt的shell的总结【转】
  5. Linux下PHP安装oci8扩展
  6. 解剖SQLSERVER 第六篇 对OrcaMDF的系统测试里避免regressions(译)
  7. win下修改mysql默认的字符集以防止乱码出现
  8. 案例研究:Web应用间歇性SqlException
  9. 使用ruby过程中遇到安装gem失败的一些通用解决方案
  10. Java连接Oracle数据库开发银行管理系统【二、设计篇】