【发布时间】:2015-09-16 20:33:40
【问题描述】:
当我设置 margin-right: 50px;我没有看到任何效果,但是当我替换 margin-right: 50px;左边距:50px;或边距顶部:50px;我确实看到了效果。这是margin-right的代码...
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Max Pietsch homepage</title>
<style type="text/css">
.me {
margin-right: 20px;
}
#pic_of_me {
width: 200px;
}
</style>
</head>
<body>
<div class="me">
<img id="pic_of_me" src="me.jpg" alt="A picture of me">
</div>
</body>
【问题讨论】:
-
那是...不是margin-right的代码。
-
你希望margin-right做什么?
-
看不到
margin-right -
假设您打算在上面的 sn-p 中放置
margin-right而不是top,它确实有效,但.me是一个块元素,因此占用了整行。您可以看到它在this example by adding background colours 中有效。注意删除 div 右边距时会发生什么。 -
尝试填充一些内容(长文本),它会工作