代码在下面,点击黄色按钮,红色的框总是少一块,最外层div比刚开始的小,是为什么呢
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
height: 100%;
}
.wrap {
width: 100%;
height: 100%;
}
.informationBar {
width: 100%;
height: 10%;
}
.OpenorClose {
width: 100%;
height: 100%;
background: yellow;
}
.menu {
width: 75px;
height: 90%;
float: left;
background: #181f24;
}
.content {
height: 90%;
background: red;
float: left;
}
</style>
</head>
<body>
<div class="wrap">
<div class="informationBar">
<div class="OpenorClose">
点击我
</div>
</div>
<div class="menu"></div>
<div class="content"></div>
<div class="clear"></div>
</div>
</body>
</html>
<script type="text/javascript">
$(".content").css("width", $(window).width() - $(".menu").width() + "px");
var c = true;
$(".OpenorClose").click(function() {
if(c == true) {
$(".menu").css("width", "183px");
$(".content").css("width", $(window).width() - $(".menu").width() + "px");
c = false;
} else {
$(".menu").css("width", "75px");
$(".content").css("width", $(window).width() - $(".menu").width() + "px");
c = true;
}
})
</script>