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

为什么我的left跑到下面去了?求大神指教

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
<style type="text/css">
body{ margin:0; padding:0; font-size:30px; color:#fff}
.top{width:100%;height:100px;background:#ccc;}
.main{width:100%;height:600px;background:red;}
.left{ width:200px;height:600px;background:blue;float: left;}
.right{height:600px;background:#9acc99;margin:0 0 0 210px;}
.foot{width:100%;height:50px;background:#ff6634;}
</style>

</head>

<body>
<div class="top">top</div>
<div class="main">
    <div class="right">right</div>
    <div class="left">left</div>
</div>
<div class="foot">foot</div>

</body>
</html>



正在回答

2 回答

body 里面你的div顺序是先right 后left,right没有浮动自占一行,然后下面再排left。

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

<style type="text/css">
body{ margin:0; padding:0; font-size:30px; color:#fff}
.top{width:100%;height:100px;background:#ccc;}
.main{width:100%;height:600px;background:red;}
.left{ width:200px;height:600px;background:blue;position: absolute;top: 100px;left: 0}
.right{height:600px;background:#9acc99;margin-left:210px;}
.foot{width:100%;height:50px;background:#ff6634;}
</style>

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

举报

0/150
提交
取消
如何用CSS进行网页布局
  • 参与学习       209682    人
  • 解答问题       1153    个

用最简洁的案例教你布局的那些知识,这是前端工程师基本技能

进入课程

为什么我的left跑到下面去了?求大神指教

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信