开发者社区> 问答> 正文

margin-left失效

<div class="area clearfix">
   <div class="box"></div>
</div>
css
.area {
  width: 400px;
  height: 400px;
  background: red;
}
.area .box {
  width: 100px;
  height: 100px;
  background: green;
  float: right;
  margin-left:1000px
}
这里的margin-left为什么失效?因为右浮动的关系吗?

展开
收起
a123456678 2016-05-27 17:54:16 2087 0
1 条回答
写回答
取消 提交回答
  • float: right;
    margin-left:1000px
    the reason why this code doesn't work is that you can't combine "float:right and margin-left",target css code can write as below:

    float:right
    margin-right:-1000px
    or

    float:left
    margin-left:-1000px
    you can have a try

    2019-07-17 19:18:32
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Top 5 mistakes when wriiting a 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载