为了账号安全,请及时绑定邮箱和手机立即绑定

我这里的绝对定位为什么不能用top?

<!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">
*{margin:0; padding:0;}
#wrap{width:970px; 【任务1】 margin:0 auto;}
#mainbody{【任务3】position:relative; margin-top:15px;}
#left{【任务2】width:110px; float:left; margin-top:10px;}
#mid{【任务2】width:650px;border:1px solid #999; float:left; margin:13px;}
#right{【任务3】position:absolute; top:50px; border:1px solid #999;}<!--这里为什么不能用top属性,而要用margin-top?-->
</style>
</head>

<body>
<div id="wrap">
     <div id="header"><img src="http://img1.sycdn.imooc.com//5369cd6e0001a15b09700088.jpg" width="970" height="88" /></div>
     <div id="mainbody">
          <div id="left"><img src="http://img1.sycdn.imooc.com//5369cd0e00011e3901090487.jpg" width="109" height="487" /></div>
          <div id="mid"><img src="http://img1.sycdn.imooc.com//5369cd3c00013e9e06490439.jpg" width="649" height="439" /></div>
          <div id="right"><p>欢迎使用金山软件出品的爱词霸,在线查询你英语词汇、句子释义</p><img src="http://img1.sycdn.imooc.com//5369cd540001d8e101770329.jpg" width="177" height="329" /></div>
  </div>
</div>
</body>
</html>

#right{【任务3】中为什么不能用top属性,而要用margin-top?

正在回答

1 回答

因为他要产生的是外边距的效果  虽然效果一样 但是某些方面想表现的就不同了  就好比Border-top  就会在不同的位置

0 回复 有任何疑惑可以回复我~
#1

qq_Aries

border-top的位置是一样的
2015-10-30 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
网页布局基础
  • 参与学习       214672    人
  • 解答问题       1833    个

让你精通CSS中三大定位机制,彻底掌握网页布局的相关知识

进入课程

我这里的绝对定位为什么不能用top?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号