1.overflow: hidden; 清除子元素的浮动对父元素的影响
2.clear: both; 清除哥哥元素的浮动对弟弟元素的影响
3.:after{ display: block; content: “”; clear: both; }
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>选项卡</title>
<style type="text/css">
* {
margin: 0px;
padding: 0px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
-webkit-user-select: none;
}
ul, li {
list-style: none;
}
.box {
width: 500px;
margin: 10px auto;
}
.box ul {
position: relative;
top: 1px;
}
.box ul:after {
display: block;
content: "";
clear: both;
}
.box ul li {
float: left;
margin-right: 15px;
width: 100px;
height: 30px;
border: 1px solid #337ab7;
line-height: 30px;
text-align: center;
cursor: pointer;
}
.box ul li.select {
background: #5bc0de;
border-bottom-color: #5bc0de;
}
.box div {
display: none;
height: 150px;
text-align: center;
line-height: 150px;
background: