<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<style type="text/css">
.topbranch {
width: 0px;
height: 0px;
/*
* TODO: 上枝叶效果
*/
float: left;
margin-left: 100px;
border-top: 100px solid transparent;
border-left: 100px solid rgba(0, 0, 0, 0);
border-right: 100px solid rgba(0, 0, 0, 0);
border-bottom: 100px solid rgb(0, 128, 0);
}
.middleBranch {
width: 0px;
height: 0px;
/*
* TODO: 中枝叶效果
*/
border-top: 200px solid rgba(0, 0, 0, 0);
border-bottom: 200px solid rgb(0, 128, 0);
border-left:200px solid rgba(0, 0, 0, 0);
border-right:200px solid rgba(0, 0, 0, 0);
}
.base {
/*
* TODO: 树干效果
*/
float: left;
height: 200px;
width: 70px;
background-color: gray;
margin-left: 165px;
}
</style>
</head>
<body>
<section class="topbranch"></section>
<section class="middleBranch"></section>
<section class="base"></section>
</body>
</html>
题目出的不好,可以直接用margin: 0 auto实现居中,不需要浮动