PHP编写的九九乘法表.梯形和方形九九乘法表.将每一个乘法式都放在表格里面,界面美观不凌乱.
- <!doctype HTML>
- <html>
- <head>
- <title>九九乘法表</title>
- <style type="text/css">
- body{
- background:#F5F5DC;
- }
- table,td{
- border:none;
- }
- td{
- width:80px;
- height:30px;
- text-align:center;
- color:red;
- }
- .trbg{
- background:#ffe4c4;
- }
- .tdbg{
- background:#00fa9a;
- cursor:pointer;
- }
- .trbgg{
- background:#e9967a;
- }
- caption{
- color:#b8860b;
- }
- </style>
- </head>
- <?php
- $line=str_repeat('-',24);
- ?>
- <body>
- <table>
- <caption><?php echo $line.'梯形九九乘法表'.$line ?></caption>
- <?php
- for($i=1;$i<=9;$i++){
- $color=$i%2==0 ? ' trbg' : 'trbgg';
- echo '<tr class="'.$color."">\n";
- for($j=1;$j<=$i;$j++){
- echo '<td>'.$j.'*'.$i.'='.$j*$i."</td>\n";
- }
- echo "</tr>\n";
- }
- ?>
- </table>
- <table>
- <caption><?php echo $line.'方形九九乘法表'.$line ?></caption>
- <?php
- for($i=1;$i<=9;$i++){
- $color=$i%2==1 ? ' trbg' : 'trbgg';
- echo '<tr class="'.$color."">\n";
- for($j=1;$j<=9;$j++){
- echo " <td>$i*$j=".$i*$j."</td>\n";
- }
- echo "</tr>\n";
- }
- ?>
- </table>
- <a id="link"></a>
- <script type="text/javascript">
- var td=document.getElementsByTagName('td');
- for(var i in td){
- if(typeof(td[i]=='object')){
- td[i].onmouseover=function(){
- this.className='tdbg';
- this.title=this.innerHTML;
- this.onclick=function(){
- if(confirm(this.innerHTML + '\r\n是否需要了解更多?')){
- var link=document.getElementById('link');
- link.href='http://www.51-n.com/';
- link.click();
- }
- }
- }
- td[i].onmouseout=function(){
- if(!document.all){
- this.removeAttribute('class');
- this.removeAttribute('title');
- }else{
- this.className='';
- this.title='';
- }
- }
- }
- }
- </script>
- </body>
- </html>
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?新建账号
×
|