1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| <!DOCTYPE html>
<html lang="fr" dir="ltr">
<head>
<meta http-equiv="cache-control" content="public, max-age=60">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta name="author" content="Daniel Hagnoul">
<title>test</title>
<style>
* {
box-sizing: border-box;
}
table {
margin: auto;
border: 1pt solid grey;
border-spacing: 0;
}
th, td {
min-width: 10rem;
max-width: 20rem;
padding: 0.3rem;
border: 1pt solid grey;
}
#oneRow {
color: red;
}
.colorCell {
background-color: rgba( 100, 25, 75, 0.25 );
}
</style>
<script>
'use strict';
document.addEventListener( "DOMContentLoaded", ev => {
}, false );
window.addEventListener( "load", ev => {
const
elemTbody = document.querySelector( "table > tbody" ),
elemRow = elemTbody.insertRow( -1 ),
elemCell = elemRow.insertCell( -1 );
elemRow.setAttribute( "id", "oneCell" );
elemCell.setAttribute( "class", "colorCell" );
elemCell.textContent = "Une cellule";
const
elemCell3 = elemRow.insertCell( -1 );
elemCell3.setAttribute( "colspan", 3 );
elemCell3.style.textAlign = "center";
elemCell3.textContent = "Une grande cellule";
}, false );
</script>
</head>
<body>
<table>
<thead>
<tr>
<th>head1</th>
<th>head2</th>
<th>head3</th>
<th>head4</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</body>
</html> |
Partager