您的位置:首页 > Web前端 > CSS

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: