猿问

请问margin-left 和left为什么影响不同,怎么理解呢

#top{width:100%; 

overflow:hidden;

border-bottom:1px solid #dadad9;

background:#fff; 

float:left; 

【任务2】position:fixed;margin-top:0;margin-left:0; 

text-align:center;}

#top input{border:none;}


.left{float:left; margin-left:10px;}

.search{float:left; margin-left:10px; margin-top:7px;}

.select_btn{background:url(images/select_top.gif) no-repeat; width:57px; height:42px; cursor:pointer; float:left;}

.search_input{background:url(images/input_search.gif) no-repeat; width:104px; height:28px; float:left; padding-left:5px;}

.search_btn{background:url(images/search_btn.gif) no-repeat; width:29px; height:28px; float:left;}


.right{float:right; margin-right:10px; padding:5px 10px 0; border-left:1px solid #f5f5f5; border-right:1px solid #f5f5f5; height:37px;}

.topbtn{background:url(images/top_btn.gif) no-repeat; width:54px; height:30px; line-height:30px; color:#444;}


.margin_l_10{margin-left:10px;}

.margin_t_5{margin-top:5px;}

.center{margin:0 15px;}

.center_r{margin-right:15px;}


#mainbody{width:80%; 

overflow:hidden; 

【任务2】margin:0 auto;

【任务3】padding:63px;}

.content{width:236px; border:1px solid #dcdcda; float:left;}

.content li{margin-bottom:15px; text-align:center;}

.content li h2{text-align:left; padding:12px 15px; font-weight:normal; color:#444; background:#fff; margin-top:-3px; background:#fafafa;}

.content li dl{border-top:1px solid #f2f2f2; text-align:left;}

.content li dt{padding:15px; float:left; border-right:1px solid #f2f2f2;}

.content li dd{padding-top:18px; text-indent:15px;}

.content li dd a{color:#9e7e6b;}


#footer{width:100%; background:#fff; text-align:center; padding:20px 0; color:#999; border-top:#ccc; margin-top:20px;}

</style>

</head>


<body>

<div id="top">

  <div class="left">

    <div class="select_btn"></div>

    <div class="search">

      <input type="text" class="search_input" />

      <input type="button" class="search_btn" />

    </div>

  </div>

  

<div class="right">

    <input type="button" value="登录" class="topbtn" />

    <input type="button" value="注册" class="topbtn margin_l_10" />

  </div>

</div>

<div id="mainbody">

  <div class="content">


当我任务2中写 margin-left 时,任务3 写margin时无法实现 mainbody 下移,只能通过padding:63px.

而写left、top 时,任务3就可以用margin下移。

请问这两种情况怎么理解呢

qq_電波_03505597
浏览 1288回答 1
1回答
随时随地看视频慕课网APP
我要回答