让两个<div>在一个<div>里水平显示
2016-05-07 13:29
459 查看
给左边的<div>添加float属性,float:left;
********************************************************************************
<head>
<style>
body{
width:30em;
height:30em;
}
#bigBox{
background-color: #fffccf;
width:19em;
height: 10em;
margin-left: 3em;
margin-top: 3em;
border:1px solid #5B75B7;
}
#smallBox_1{
background-color:rgb(169,191,93);
width:5em;
height:2em;
padding-left: 1em;
padding-top: 1em;
margin-right: 2em;
margin-left:1em;
margin-top:1em;
border:1px solid #5B75B7;
float:left;
}
#smallBox_2{
background-color:rgb(162,111,93);
width:3em;
height:3em;
margin-left: 8em;
margin-top: 1em;
border:1px solid #5B75B7;
}
</style>
</head>
<body>
<div id="bigBox">
<div id="smallBox_1"></div>
<div id="smallBox_2"></div>
</div>
</body>
*********************************************************************************
********************************************************************************
<head>
<style>
body{
width:30em;
height:30em;
}
#bigBox{
background-color: #fffccf;
width:19em;
height: 10em;
margin-left: 3em;
margin-top: 3em;
border:1px solid #5B75B7;
}
#smallBox_1{
background-color:rgb(169,191,93);
width:5em;
height:2em;
padding-left: 1em;
padding-top: 1em;
margin-right: 2em;
margin-left:1em;
margin-top:1em;
border:1px solid #5B75B7;
float:left;
}
#smallBox_2{
background-color:rgb(162,111,93);
width:3em;
height:3em;
margin-left: 8em;
margin-top: 1em;
border:1px solid #5B75B7;
}
</style>
</head>
<body>
<div id="bigBox">
<div id="smallBox_1"></div>
<div id="smallBox_2"></div>
</div>
</body>
*********************************************************************************
相关文章推荐
- Web布局连载——两栏固定布局(五)
- [div+css]晒晒最新制作专题推广页模板
- 盒子模型
- CSS选择器
- CSS样式优先权
- [css] line-height 百分比单位和数值单位的区别
- Apple官网研究之使用Justify布局导航
- 关于前端的思考与感悟
- 设计更快的网页(三):字体和 CSS 调整
- 纯CSS制作的新闻网站中的文章列表
- 10条影响CSS渲染速度的写法与使用建议第1/3页
- BS项目中的CSS架构_仅加载自己需要的CSS
- 很不错的 CSS Hack 又学了一招
- 发一个css比较清爽的写法
- CSS expression控制图片自动缩放效果代码[兼容 IE,Firefox]
- css布局网页水平居中常用方法
- CSS经典技巧十则第1/2页
- css 兼容性问题this.style.cursor=''hand''
- IE6不能正常解析CSS文件问题的解决方法及原因分析