একটি স্থির শিরোনাম সারি এবং প্রথম কলাম সহ একটি আসল খাঁটি CSS সমাধান solution
খাঁটি সিএসএস ব্যবহার করে আমাকে একটি স্থির শিরোনাম এবং একটি স্থির প্রথম কলাম উভয় দিয়ে একটি টেবিল তৈরি করতে হয়েছিল এবং এখানে উত্তরগুলির কোনওটিরই আমি যা চেয়েছিলাম তা যথেষ্ট নয়।
position: stickyসম্পত্তি শীর্ষে উভয় স্টিকিং সমর্থন (যেমন আমি দেখেছি এটা সবচেয়ে ব্যবহৃত) এবং Chrome, ফায়ারফক্স, এবং এজ আধুনিক সংস্করণে পাশ থেকে। এটি এমন একটির সাথে মিলিত হতে পারে divযা overflow: scrollআপনাকে স্থির শিরোনামযুক্ত একটি টেবিল দেওয়ার সম্পত্তি রাখে যা আপনার পৃষ্ঠায় যে কোনও জায়গায় রাখা যেতে পারে:
আপনার টেবিলটি একটি পাত্রে রাখুন:
<div class="container">
<table></table>
</div>
overflow: scrollস্ক্রোলিং সক্ষম করতে আপনার ধারকটিতে ব্যবহার করুন:
div.container {
overflow: scroll;
}
ডাগমার মন্তব্যে যেমন উল্লেখ করেছেন, ধারকটির জন্যও a max-widthএবং a প্রয়োজন max-height।
ব্যবহার করুন position: stickyসারণীর কক্ষের আছে লাঠি এবং প্রান্ত থেকে top, rightঅথবা leftবিদ্ধ যা প্রান্ত পছন্দ করে নিন:
thead th {
position: -webkit-sticky;
position: sticky;
top: 0;
}
tbody th {
position: -webkit-sticky;
position: sticky;
left: 0;
}
হিসাবে MarredCheese মন্তব্য উল্লেখ করা হয়েছে, যদি আপনার প্রথম কলামটি রয়েছে <td>পরিবর্তে উপাদান <th>উপাদান, আপনি ব্যবহার করতে পারেন tbody td:first-childআপনার CSS এ পরিবর্তেtbody th
প্রথম কলামে শিরোনামটি বামদিকে আটকে রাখতে ব্যবহার করুন:
thead th:first-child {
left: 0;
z-index: 1;
}
div {
max-width: 400px;
max-height: 150px;
overflow: scroll;
}
thead th {
position: -webkit-sticky;
position: sticky;
top: 0;
}
tbody th {
position: -webkit-sticky;
position: sticky;
left: 0;
}
thead th:first-child {
left: 0;
z-index: 2;
}
thead th {
background: #000;
color: #FFF;
z-index: 1;
}
tbody th {
background: #FFF;
border-right: 1px solid #CCC;
box-shadow: 1px 0 0 0 #ccc;
}
table {
border-collapse: collapse;
}
td,
th {
padding: 0.5em;
}
<div>
<table>
<thead>
<tr>
<th></th>
<th>headheadhead</th>
<th>headheadhead</th>
<th>headheadhead</th>
<th>headheadhead</th>
<th>headheadhead</th>
<th>headheadhead</th>
<th>headheadhead</th>
</tr>
</thead>
<tbody>
<tr>
<th>head</th>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
</tr>
<tr>
<th>head</th>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
</tr>
<tr>
<th>head</th>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
</tr>
<tr>
<th>head</th>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
</tr>
<tr>
<th>head</th>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
</tr>
<tr>
<th>head</th>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
<td>body</td>
</tr>
</tbody>
</table>
</div>
https://jsfiddle.net/qwubvg9m/1/