About the layout method of content overflow in table

About the layout method of content overflow in table

What is content overflow? In fact, when there is a lot of text, if the content area is only that long, then the extra part will be replaced by dots.

The case we are doing this time is in a table. We know that when we enter too much text content in a table, the table will be messed up, for example, a line will be displayed too long or automatically wrapped. But sometimes we just want to display it in a row of fixed width, and if there is any extra part, we can replace it with dots, so as not to clutter the table. So what to do?

Generally we will use the following attributes

CSS CodeCopy content to clipboard
  1. /*Overflow part style*/   
  2. .txt-ell {
  3.      white white-space : nowrap ; //Force to display in one line
  4.      overflow : hidden ; //Cut and hide overflow content
  5. text- overflow :ellipsis; //When the inline overflows the block container, replace the overflow part with...
  6. word-break:keep- all ; //Allow line breaks within words
  7.      color : red ; // I will mark it here myself
  8.      padding : 0 7px ; //Because I want to leave some distance from the edge, I set the following
  9. }
CSS CodeCopy content to clipboard
  1. .table-fix {
  2.      table-layout : fixed ;
  3. }

First of all, the second style is specifically added to the table tag. If you want to achieve content overflow, the table must have a fixed width and height, and the tr and td inside the table must also have a fixed width and height. Before using content overflow, add the table-fix class to the table. Then check if your tr and td have a width. If not, it is best to give one. It can be fixed or in percentage. I mainly give percentages. The outer table has a fixed width, and the tr and td inside have a percentage width. This way, you can use the content overflow style. Finally, if there is a lot of content in a grid and you want to implement dots, add a .txt-ell class to this grid.

The above article about the content overflow layout method in the table is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

Original URL: http://www.cnblogs.com/hanyining/archive/2016/05/25/5527668.html

<<:  CSS3 creates 3D cube loading effects

>>:  Detailed explanation of Vue3's responsive principle

Recommend

Vue achieves seamless carousel effect

This article shares the specific code of Vue to a...

vue front-end HbuliderEslint real-time verification automatic repair settings

Table of contents ESLint plugin installation in H...

Use pictures to realize personalized underline of hyperlinks

Don't be surprised if you see some kind of und...

Analyze Tomcat architecture principles to architecture design

Table of contents 1. Learning Objectives 1.1. Mas...

MySQL 8.0.12 winx64 decompression version installation graphic tutorial

Recorded the installation of mysql-8.0.12-winx64 ...

Prevent HTML and JSP pages from being cached and re-fetched from the web server

After the user logs out, if the back button on the...

In-depth study of vue2.x--Explanation of the h function

Table of contents Solution, Summarize: vue projec...

How to achieve seamless token refresh

Table of contents 1. Demand Method 1 Method 2 Met...

How to run Python script on Docker

First create a specific project directory for you...

Vue storage contains a solution for Boolean values

Vue stores storage with Boolean values I encounte...

How to use echarts to visualize components in Vue

echarts component official website address: https...

A brief analysis of the difference between ref and toRef in Vue3

1. ref is copied, the view will be updated If you...

A Deeper Look at SQL Injection

1. What is SQL injection? Sql injection is an att...

How to create a my.ini file in the MySQL 5.7.19 installation directory

In the previous article, I introduced the detaile...