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

在一个div中有两个子元素,子元素浮动,左边div高度随右边变化

2017-07-31 09:01 330 查看
思路:用jquery获取右边盒子高度给左边
<style type="text/css">
.clearfix:after {
content: '';
display: block;
clear: both;
}

.clearfix {
zoom: 1;
}
</style>
<body>
<div class="" style="width: 100%; margin: 0 auto;">
<div class="clearfix" style="width: 500px;">
<div style="float: left; width: 50px; height: 100px; background: yellow;" class="fl">

</div>
<div style="float: left; width: 100px; height: 100px; background: red;" class="ri">

</div>
</div>
</div>
<script type="text/javascript">
$(".ri").outerHeight()
console.log($(".ri").outerHeight())
$(".fl").css("height", $(".ri").outerHeight())
</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jquery
相关文章推荐