티스토리 뷰
Optimizing Complex Data for Small Screens: How to Create the Scrolling Tables
JoyJaewon 2023. 2. 23. 02:28As a web developer, creating a user-friendly and responsive website is always my top priority. I believe that designing for the user's perspective is key to creating a successful website that is easy to use and navigate. When it comes to presenting complex data in tables, it can be especially tricky to make them easy to use and read on small screens. When I first received the task to make the tables that would be easy to use and read on mobile devices, I had to do a lot of research. There was the design given by the designer, but I believed there might be the better way to present the table to the users more efficiently. I did some research, created several different designs and presented them to the product managers. In the end, the scrollable table was the best option for presenting complex data in a way that was both user-friendly and optimized for any device. Today, I will talk about how to create a scrollable table using CSS and also Bootstrap 5.
1. Using CSS
To make a responsive table using CSS, you can start with a basic HTML table structure and then add CSS properties to control its appearance and behavior. One common approach is to set the table's width to 100% and its display property to block. This will make the table fill the entire width of its container and allow it to be responsive to changes in screen size.
Next, you can add overflow-x: auto to the table's CSS to enable horizontal scrolling on small screens. This property allows the table to remain the same width while users can scroll left or right to view the entire table.
If you have a large table with a lot of data, you may also want to consider adding a fixed header to make the table more user-friendly. You can achieve this by using the CSS position: sticky property on the th elements within the thead section of your table. This will keep the header fixed at the top of the table as users scroll through the data.
2. Using Bootstrap 5
Tables
Documentation and examples for opt-in styling of tables (given their prevalent use in JavaScript plugins) with Bootstrap.
getbootstrap.com
Bootstrap 5 provides a built-in class called table-responsive that makes it easy to create a responsive table. To use this class, we can simply add it to the parent element of the table, which is typically a <div> element.
<div class="table-responsive">
<table class="table">
<thead></thead>
<tbody></tbody>
</table>
</div>
In this example, we wrap the table in a <div> element with the table-responsive class. This tells Bootstrap to make the table scrollable on small screens, so users can easily view the table without having to zoom in or out. You can choose -sm | -md | -lg | -xl depending on your breakpoint.
Creating a responsive table is crucial for providing a positive user experience on mobile devices. Whether you choose to use CSS or a front-end framework like Bootstrap 5, the key is to make the table easily readable and navigable, no matter what screen size the user is using.
Thank you for being here today, have a wonderful day! :D
'HTML+CSS' 카테고리의 다른 글
BEM Naming Convention for CSS (0) | 2023.03.03 |
---|---|
How to Use Bootstrap5 Tab (0) | 2023.02.20 |
How to Fix White Space on the Right for Mobile Devices (How a Tiny Code can Cause the Big Issue) (0) | 2023.02.16 |
- Total
- Today
- Yesterday
- Next.js
- scrollabe table
- promise.all()
- CSR
- responsive table
- JSON-CSV-Conversion
- React.js
- CSS
- bootstrap5
- responsive design
- orderByFilter
- #노개북 #노마드코더 #개발자북클럽 #클린코드
- Bootstrap5 tab
- UX
- BEM
- CSS white space issue
- handleNullData
- BEM-like-Naming
- CSV Validation
- angularjs
- frontend
- $scope.$applyAsync()
- ImportCSV
- developer tools
- Desk Setup
- junior frontend developer
- SSR
- Responsive Troubleshooting
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |