簡易九九乘法表

實現一:

<%@ page language="java" import="java.util.*,java.text.*" 
    contentType= "text/html; charset=utf-8" %>
<html>
    <head>
    <title>九九乘法表</title>
    <link rel="stylesheet" type="text/css" href="css/index.css"/>
    </head>
<body>
   <table border="1">
     <caption>乘法口訣表</caption>
     <tbody>
       <%
         for(int i=1;i<=9;i++){
        %>
        <tr>
          <%
          for(int j=1;j<=i;j++){
          %>
            <td>
             <%= j%>*<%=i %>=<%=j*i %>
            </td>
          <%} %>
        </tr>
        <%}%>
     </tbody>
   </table>
  </body>
</html>

實現二:

<%@ page contentType="text/html;charset=utf-8"%>
<html>
    <head>
    <title>九九乘法表</title>
    <link rel="stylesheet" type="text/css" href="css/index.css"/>
    </head>
<body>
   <table border="1">
     <caption>乘法口訣表</caption>
     <tbody>
       <%
          for(int i = 1; i <= 9; i++) {
              out.print("<tr>");
             for(int j = 1;j <= i; j++) {
                  out.print("<td>" + j + "*" + i + "=" + j*i + "</td>");
             }
             out.print("</tr>");
          }
        %>
     </tbody>
   </table>
  </body>
</html>

index.css

body {
    padding:0;margin: 0;
}
table{
    width: 810px;
    height: 500px;
    margin:auto;
    border-collapse: collapse;
    border: none;
    text-align: center;
    position:absolute;
    top:0;
    left:0;
    bottom:0;
    right:0;
    background-color:#000;
}
caption {
    font-size: 2rem;
    line-height: 50px;
    color: rgb(232,237,81);
}

table tr {
    height: 50px;
}
table td {
    width: 90px;
    height: 50px;
    background-color: rgb(184,247,136);

}
table td:hover {
    background-color: rgba(255,0,0,.6);
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章