<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
.triangle {
width: 0px;
height: 0px;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 100px solid red;
}
.tridown {
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 100px solid red;
}
.triangle-left {
width: 0;
height: 0;
border-top: 50px solid transparent;
border-right: 100px solid red;
border-bottom: 50px solid transparent;
}
</style>
</head>
<body>
<input id="nub" type="" name="" id="" value="" placeholder="请输入整数" />
<input onclick="turnleft()" value="移动" type="button">
<button onclick="turndown()">翻转</button>
<input onclick="tran" type="button" name="xz" id="xz" value="旋转" />
<div id="triangle" class="triangle"></div>
</body>
<script src="js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
function turnleft() {
var left = document.getElementById('nub').value;
var tri = document.getElementById('triangle');
tri.style.marginLeft = tri.style.marginLeft + left + 'px';
}
$("button").click(function() {
$("div").toggleClass('triangle').toggleClass("tridown");
});
$("#xz").click(function() {
$("div").toggleClass('triangle').toggleClass("triangle-left");
});
</script>
</html>