当前位置:编程学习 > JS >>

CSS 仿Excel表格功能,真棒

用CSS模拟出Excel表格的功能,虽然功能不如真正的Excel,但是这必竟是CSS版啊,能写出这效果,也真让人佩服啊,不错的效果,鼠标在表格内点击看看,很棒的吧~~
答案:<!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>
<title>Spreadsheet form - www.zzzyk.com</title>
<style>
table.formdata {
	border: 1px solid #5F6F7E;
	border-collapse: collapse;
}
table.formdata th {
	border: 1px solid #5F6F7E;
	background-color: #E2E2E2;
	color: #000000;
	text-align: left;
	font-weight: normal;
	padding: 2px 4px 2px 4px;
	margin: 0;
}
table.formdata td {
	margin: 0;
	padding: 0;
	border: 1px solid #E2E2E2;
}
table.formdata input {
	width: 80px;
	padding: 2px 4px 2px 4px;
	margin: 0;
	border: 2px solid #ffffff;
}
.formdata input:focus {
	border: 2px solid #000000;
}
</style>
<script language="javascript" type="text/javascript">
function hilite(obj) {
	obj.style.border = '2px solid #000000';
}

function delite(obj) {
	obj.style.border = '2px solid #ffffff';
}
</script>
</head>
<body>
<form method="post" action="spreadsheet.html">
<table class="formdata" summary="This table contains a form to input the yearly income for years 1999 through 2002">
  <caption>Complete the Yearly Income 1999 - 2002</caption>
  <tr>
    <th></th>
    <th scope="col">1999</th>
    <th scope="col">2000</th>
    <th scope="col">2001</th>
    <th scope="col">2002</th>
  </tr>
  <tr>
    <th scope="row">Grants</th>
    <td><input type="text" name="grants1999" id="grants1999" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="grants2000" id="grants2000" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="grants2001" id="grants2001" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="grants2002" id="grants2002" onfocus="hilite(this);" onblur="delite(this);" /></td>
  </tr>
  <tr>
    <th scope="row">Donations</th>
    <td><input type="text" name="donations1999" id="donations1999" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="donations2000" id="donations2000" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="donations2001" id="donations2001" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="donations2002" id="donations2002" onfocus="hilite(this);" onblur="delite(this);" /></td>
  </tr>
  <tr>
    <th scope="row">Investments</th>
    <td><input type="text" name="investments1999" id="investments1999" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="investments2000" id="investments2000" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="investments2001" id="investments2001" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="investments2002" id="investments2002" onfocus="hilite(this);" onblur="delite(this);" /></td>
  </tr>
  <tr>
    <th scope="row">Fundraising</th>
    <td><input type="text" name="fundraising1999" id="fundraising1999" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="fundraising2000" id="fundraising2000" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="fundraising2001" id="fundraising2001" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="fundraising2002" id="fundraising2002" onfocus="hilite(this);" onblur="delite(this);" /></td>
  </tr>
  <tr>
    <th scope="row">Sales</th>
    <td><input type="text" name="sales1999" id="sales1999" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="sales2000" id="sales2000" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="sales2001" id="sales2001" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="sales2002" id="sales2002" onfocus="hilite(this);" onblur="delite(this);" /></td>
  </tr>
  <tr>
    <th scope="row">Miscellaneous</th>
    <td><input type="text" name="misc1999" id="misc1999" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="misc2000" id="misc2000" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="misc2001" id="misc2001" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="misc2002" id="misc2002" onfocus="hilite(this);" onblur="delite(this);" /></td>
  </tr>
  <tr>
    <th scope="row">Total</th>
    <td><input type="text" name="total1999" id="total1999" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="total2000" id="total2000" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="total2001" id="total2001" onfocus="hilite(this);" onblur="delite(this);" /></td>
    <td><input type="text" name="total2002" id="total2002" onfocus="hilite(this);" onblur="delite(this);" /></td>
  </tr>
</table>
<p><input type="submit" name="btnSubmit" id="btnSubmit" value="Add Data" /></p>
</form>
</body>
</html>

上一个:超小代码实现文字动画,出自1K写出3D圣诞树的作者
下一个:采用css3的语言框效果

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,