第一列和第一行锁定的HTML

时间:2015-06-10 15:11:16

标签: javascript html css

我有一个html文件,它是从Microsoft Excel应用程序导出为HTML,我想冻结html中的第一行和第一行,当我尝试添加position:fixed;时,标题的大小和对齐方式正在增加改变。 请告知如何在不改变对齐和尺寸的情况下完成任务。 我已粘贴了html的源代码。 对我来说这将是一个很大的帮助,在此先感谢。 大卫。 enter image description here



<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 14">

<style id="STORE-FREEZE_14759_Styles">
<!--table
	{mso-displayed-decimal-separator:"\.";
	mso-displayed-thousand-separator:"\,";}
.xl1514759
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:black;
	font-size:11.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl6314759
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:white;
	font-size:9.0pt;
	font-weight:700;
	font-style:normal;
	text-decoration:none;
	font-family:Calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:left;
	vertical-align:middle;
	border:2.0pt double #3F3F3F;
	background:#4BACC6;
	mso-pattern:black none;
	white-space:normal;}
.xl6414759
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:white;
	font-size:9.0pt;
	font-weight:700;
	font-style:normal;
	text-decoration:none;
	font-family:Calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:center;
	vertical-align:middle;
	border:2.0pt double #3F3F3F;
	background:#4BACC6;
	mso-pattern:black none;
	white-space:normal;}
.xl6514759
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:black;
	font-size:9.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:center;
	vertical-align:middle;
	border:.5pt solid windowtext;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl6614759
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:black;
	font-size:9.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:left;
	vertical-align:middle;
	border-top:.5pt solid windowtext;
	border-right:none;
	border-bottom:.5pt solid windowtext;
	border-left:none;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl6714759
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:black;
	font-size:9.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:left;
	vertical-align:middle;
	border-top:.5pt solid windowtext;
	border-right:none;
	border-bottom:.5pt solid windowtext;
	border-left:.5pt solid windowtext;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl6814759
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:black;
	font-size:9.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:"\#\,\#\#0_\)\;\\\(\#\,\#\#0\\\)";
	text-align:center;
	vertical-align:middle;
	border-top:.5pt solid windowtext;
	border-right:.5pt solid windowtext;
	border-bottom:.5pt solid windowtext;
	border-left:1.0pt solid windowtext;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl6914759
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:white;
	font-size:9.0pt;
	font-weight:700;
	font-style:normal;
	text-decoration:none;
	font-family:Calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:center;
	vertical-align:middle;
	border-top:1.0pt solid windowtext;
	border-right:.5pt solid windowtext;
	border-bottom:.5pt solid windowtext;
	border-left:1.0pt solid windowtext;
	background:#4BACC6;
	mso-pattern:black none;
	white-space:normal;}
-->
</style>
</head>

<body>
<!--[if !excel]>&nbsp;&nbsp;<![endif]-->
<!--The following information was generated by Microsoft Excel's Publish as Web
Page wizard.-->
<!--If the same item is republished from Excel, all information between the DIV
tags will be replaced.-->
<!----------------------------->
<!--START OF OUTPUT FROM EXCEL PUBLISH AS WEB PAGE WIZARD -->
<!----------------------------->

<div id="STORE-FREEZE_14759" align=center x:publishsource="Excel">

<table border=0 cellpadding=0 cellspacing=0 width=355 style='border-collapse:
 collapse;table-layout:fixed;width:267pt'>
 <col width=51 style='mso-width-source:userset;mso-width-alt:1865;width:38pt'>
 <col width=46 style='mso-width-source:userset;mso-width-alt:1682;width:35pt'>
 <col width=176 style='mso-width-source:userset;mso-width-alt:6436;width:132pt'>
 <col width=82 style='mso-width-source:userset;mso-width-alt:2998;width:62pt'>
 <tr height=66 style='height:49.5pt'>
  <td height=66 class=xl6414759 width=51 style='height:49.5pt;width:38pt'>SL.NO</td>
  <td class=xl6314759 width=46 style='border-left:none;width:35pt'>TYPE</td>
  <td class=xl6314759 width=176 style='border-left:none;width:132pt'>LOCATION</td>
  <td class=xl6914759 width=82 style='width:62pt'>BRAND</td>
 </tr>
 <tr height=21 style='height:15.75pt'>
  <td height=21 class=xl6514759 style='height:15.75pt'>1</td>
  <td class=xl6614759>S1</td>
  <td class=xl6714759>INDIA</td>
  <td class=xl6814759 style='border-top:none'>3G</td>
 </tr>
 <tr height=20 style='height:15.0pt'>
  <td height=20 class=xl6514759 style='height:15.0pt;border-top:none'>2</td>
  <td class=xl6614759 style='border-top:none'>S1</td>
  <td class=xl6714759 style='border-top:none'>INDIA</td>
  <td class=xl6814759 style='border-top:none'>3G</td>
 </tr>
 <tr height=20 style='height:15.0pt'>
  <td height=20 class=xl6514759 style='height:15.0pt;border-top:none'>3</td>
  <td class=xl6614759 style='border-top:none'>S1</td>
  <td class=xl6714759 style='border-top:none'>INDIA</td>
  <td class=xl6814759 style='border-top:none'>3G</td>
 </tr>
 <![if supportMisalignedColumns]>
 <tr height=0 style='display:none'>
  <td width=51 style='width:38pt'></td>
  <td width=46 style='width:35pt'></td>
  <td width=176 style='width:132pt'></td>
  <td width=82 style='width:62pt'></td>
 </tr>
 <![endif]>
</table>

</div>


<!----------------------------->
<!--END OF OUTPUT FROM EXCEL PUBLISH AS WEB PAGE WIZARD-->
<!----------------------------->
</body>

</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

好吧,如果您想要修复HTML标题行和第1列,那么它会比您想象的更加谨慎。

  1. 步骤1:创建一个包含仅包含标题行的表的DIV。
  2. 将DIV设置为固定并将溢出X设置为显示。
  3. 使用仅包含1列的表创建DIV,它将包含固定的第1列。
  4. 将DIV设置为固定,将溢出Y设置为
  5. 使用包含剩余数据的表创建DIV。
  6. 将DIV设置为固定,将溢出设置为自动。
  7. 现在,如果您想要1 X轴和1 y轴滚动条,请参阅:Scroll 2 scrollbars with jquery the same time

    如果您需要一些示例代码,请与我们联系。

相关问题