显示带有边距的div宽度100% [英] Display a div width 100% with margins

查看:372
本文介绍了显示带有边距的div宽度100%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示一个可扩展的 div width:100%)带边距...

I want to display an expandable div (width: 100%) with margins...

这是我的代码:

<div id="page">
    <div id="margin">
        "some content here"
    </div>
</div>​

这里是我的css代码:

And here is my css code :

#page {
  background: red;
  float: left;
  width: 100%;
  height: 300px;
}

#margin {
  background: green;
  float: left;
  width: 100%;
  height: 300px;
  margin: 10px;
}​

LIVE DEMO

LIVE DEMO

推荐答案

您可以使用以下CSS所需结果:

You can use the following CSS to achieve the desired result:

#page {
   background: red;
   overflow: auto;
}

#margin {
   background: green;
   height: 280px;
   margin: 10px
}

这篇关于显示带有边距的div宽度100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆