Now the table content needs to display the following requirements:
1, the table is large, the interface is not small, you need to put in the Div.
2, in the Div can be viewed with scroll slide.
3, the contents of TD are kept in one line.
4, you can click on the TR, then you can select and understand which line is clicked.
Html:
<div id= "Div1" >
<table id= "Table1" >
<tr></tr>
</table>
<div>
Css:
The div width is smaller than table and there is scroll.
#table1 {border-collapse:collapse;height:100;}
#table1 table, Th, TD {Border:1px solid black;}
#table1 td{
width:230px; /* Width is set as needed, or set to percent/
height:25px;line-height:25px; /* height is also set as required */
White-space:nowrap; /* Text display does not wrap */
/*overflow:hidden;*//* Out-of-section display */
}
#div1 {border:1px solid red;width:460; height:180px;overflow:scroll;}
Js:
Add a onmousedown event handler to the click.
var trs = document.getElementById (' table1 '). getElementsByTagName (' tr ');
var choose;
Window.onload = function () {
for (var i=0; i<trs.length; i++) {
Trs[i].onmousedown = function () {
Tronmousedown (this);
}
}
}
function Tronmousedown (obj) {
for (var o=1; o<trs.length; o++) {
if (trs[o] = = obj) {
Trs[o].style.backgroundcolor = ' lightblue ';
choose = O;
}
else{
Trs[o].style.backgroundcolor = ";
}
}
}
Can communicate with each other.
Html+css a table that can be browsed