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

为什么margin:10 200px 10 300px 相对定位的结果那么奇怪?

<!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=gb2312" />

<title>o代表垂直距离,auto代表水平距离</title>

<style type="text/css">

body{margin:0;padding:0}

.top{height:100px;width:300px;background:blue;position:absolute;left:0;top:0}

.main{height:300px;background:#ccc;margin:10 200px 10 300px}

.foot{height:100px;background:#900;width:200px;position:absolute;right:0;top:0}

</style>

</head>


<body>

<div class="top"></div>

<div class="main"></div>

<div class="foot"></div>

</body>

</html>

结果麻烦老师们自己运行一下,求解答


正在回答

3 回答

相当于选择已有节点保存起来之后赋值,这里目前只是在插入dom之前这么操作。~

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

margin:10 200px 10 300px   ——>  margin:10px 200px 10px 300px

这样应该没问题了

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

10的后边要加上单位的 px才可以哦

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

举报

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

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

进入课程

为什么margin:10 200px 10 300px 相对定位的结果那么奇怪?

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