css给父盒子加display:inline实现子盒子自动撑开 实现子盒子和父盒子都浮动
2016-05-05 23:13
417 查看
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
.box{ width:300px;margin:0 auto;border:10px solid #000; display:inline-block;}
.div{ width:200px;height:200px;background:red;float:left;}
/*
清浮动
1.给父级也加浮动
2.给父级加display:inline-block
*/
</style>
</head>
<body>
<div class="box">
<div class="div"></div>
</div>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
.box{ width:300px;margin:0 auto;border:10px solid #000; display:inline-block;}
.div{ width:200px;height:200px;background:red;float:left;}
/*
清浮动
1.给父级也加浮动
2.给父级加display:inline-block
*/
</style>
</head>
<body>
<div class="box">
<div class="div"></div>
</div>
</body>
</html>
相关文章推荐
- Qt利用QGraphicsScene编写Word排版工具导出PDF
- css父盒子没有高度让子盒子撑开 且子盒子有浮动 清除浮动
- 样式表笔记
- 关于CSS中float的两点心得以及清除浮动的总结
- css3动画学习资料整理
- 带你了解CSS开发中的10个不要
- css position relative obsolution
- 【转】CSS选择器笔记
- CSS 的优先级机制
- HTML加入CSS
- 文本框字母小写即时转大写
- CSS3:color
- CSS3 border-image详解
- HTML&CSS——琐碎的知识点(2)
- HTML&CSS——琐碎的知识点(1)
- CSS 实现:文字水平垂直居中
- CSS教程之div垂直居中的多种方法
- css中解决textarea高度随内容自适应的问题
- CSS3使用边框和背景
- 前端必须掌握30个CSS3选择器