开发者

overflow: auto - no right padding & margin, chrome

The problem is that there is no right padding in the parent div and no right margin in the child div. I am using chrome.

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Template</title>
</head>
<body>
    <div style = "padding: 50px; overflow: auto; width: 300px; height: 300px; background-color: red;">
        <div style = "width: 500px; height: 500px; background-color: green;"></div>
    </div>
    <hr />
    <div style = "overflow: auto; width: 300px; height: 300px; background-color: re开发者_开发技巧d;">
        <div style = "margin: 50px; width: 500px; height: 500px; background-color: green;"></div>
    </div>
</body>
</html>


I found the solution for padding, unfortunately it does not work with margin:

.container {
  overflow: auto;
  width: 300px;
  height: 150px;
  background-color: red;
}
.padding {
  float: left;
  padding: 50px;
}
.content {
  width: 500px;
  height: 500px;
  background-color: green;
}
<div class="container">
  <div class="padding">
    <div class="content"></div>
  </div>
</div>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜