<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>金字塔</title> <style type="text/css"> body{ font-size: 30px; } .empty{ display: inline-block; width: 40px; height: 20px; line-height: 20px; visibility: hidden; } .cont{ display: inline-block; width: 40px; height: 20px; line-height: 20px; color: black; } </style> </head> <body> <script type="text/javascript" src="js/jinzita.js" ></script> </body> </html>
for(var i=0; i<=10; i++){ for(var j=10; j>=i; j--){ document.write('<span class="empty">▲</span>'); } for(var k=0; k<=i*2; k++){ document.write('<span class="cont">▲</span>'); } document.write('<br />'); }