直接代码吧
//----------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css"> //###
tbody {color:green;height:50px text-align:center}table
  {
  border-collapse:collapse;
  height:20px;
  }table, td, th
  {
  border:1px solid green;
  }
td
{
text-align:center;
height:25px;
}
th 
{
color:green height:50px
   background-color:green;}</style>  //####
<script type="text/javascript">
function createData(){
var a={};
for(var i=0;i<256;i++){
a[i+".name"]=i+"name";
a[i+".age"]=i+'age';
a[i+".sex"]=((i&1)==0?'男':'女');
}
return a;
}
function createTable(){
for(var i=0;i<=19;i++){
var tr=document.createElement("tr");
for(var j=0;j<=2;j++){
tr.appendChild(document.createElement("td"));
}
document.getElementById("data").appendChild(tr);
}
}
function findData(x,data){
var tds=document.getElementsByTagName("td");
var j=0;
for(var i=(x-1)*20;i<x*20;i++){
tds[j++].innerHTML=data[i+'.name'];
tds[j++].innerHTML=data[i+'.age'];
tds[j++].innerHTML=data[i+'.sex'];
}
}
window.onload=function(){
var data=createData();
var isInit=false;
var f=document.getElementById("find");
var p=document.getElementById("page");
var n=document.getElementById("next");
var r=document.getElementById("pre");
f.onclick=function(){
if(!isInit){
createTable();
p.value=1;
isInit=true;
}
findData(p.value,data);
}
r.onclick=function(){
if(!isInit){
createTable();
p.value=1;
isInit=true;
}else{
p.value=parseInt(p.value)-1;
}
findData(p.value,data);
}
n.onclick=function(){
if(!isInit){
createTable();
isInit=true;
p.value=1;
}else{
p.value=parseInt(p.value)+1;
}
findData(p.value,data);
}
}
</script>
</head><body>
<div id="test">
<table>
     <tbody id="data">
         <tr>
             <th>姓名</th>
                <th>年龄</th>
                <th>性别</th>
            </tr>
        </tbody>
    </table>
</div>
<input type="button" value="查询" id="find" />
<input type="button" value="上一页" id="pre" />
<input type="button" value="下一页" id="next" />
当前页<input type="text" value="" id="page">
</body>
</html>我现在想通过CSS来设置input button的位置到中间,table的已经差不多设置好了,现在就是想让button与table的位置配对一下,怎么设置?cssjavascripthtml

解决方案 »

  1.   

      目前的样子是这样的,刚刚接触web 太多东西要学了,目前水平很有限,希望会的人指导下!
      

  2.   

    <style>
    .control{
    width:100px;//这里我是自己写的,你把这个改成你上面table的宽度即可。
    margin:0 auto; //这个可以使这个div模块居中
    }
    </style>
    <div class = "control">
    <input type="button" value="查询" id="find" />
    <input type="button" value="上一页" id="pre" />
    <input type="button" value="下一页" id="next" />
    当前页<input type="text" value="" id="page">
    </div>你这样改一下试试!