Home > Web Front-end > HTML Tutorial > The td content in the table is too long, I want to use it. . . show_html/css_WEB-ITnose

The td content in the table is too long, I want to use it. . . show_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:19:55
Original
1056 people have browsed it

The td content in the table is too long. I want to use... to display it. Key point: I want to click the mouse on... and then a layer will appear on it to display the entire content. Dear brothers and sisters, please help. ah! ! ! ! ! ! ! ! ! ! ! !


Reply to the discussion (solution)

It’s useless to talk about the truth, it’s better to give an example and write a comment, thank you! ! ! ! ! ! ! ! ! ! !

I have an idea, use the method of two-level pop-up menu

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">table {	border: #CCC 1px solid;}td,th {	width: 120px;	border: 1px solid #999;}td:hover ul {	display: block;	}ul {	display: none;	border: 1px solid #999;	list-style: none;	margin: 0;	padding: 0;	position: absolute;	width: 120px;	background: #CCC;}</style></head><body><table>  <tr>    <th>标题一</th>    <th>标题二</th>  </tr>  <tr>    <td>内容一内容……      <ul>        <li>隐藏内容一</li>      </ul>    </td>    <td>内容二内……</td>  </tr>  <tr>    <td>内容三</td>    <td>内容四</td>  </tr></table></body></html>
Copy after login

I have an idea, use the method of two-level pop-up menu


XML/HTML code? 484950515253



You can’t do this. What I mean is that if the content is too long, it will be displayed... and then move the mouse... and a layer will appear on top to display the entire content. If the content is not long, it will not be displayed. It will appear..., and the layer will not appear to display when the mouse moves the above content

I have an idea, use the secondary pop-up menu method

XML/ HTML code? 253


The difficulty is to judge, not long The content (will not be displayed...) The layer will not appear when moving

Quoting the reply from kxteb0cc on the 2nd floor: I have an idea, using the secondary pop-up menu method


XML/HTML code? 7484950515253

Uh, I understand what you mean, do you want It automatically determines whether the content is too long and then automatically hides it. I don’t know about this, but I guess it requires javascript...

Quote from quanlei1507053 on the 4th floor:
Quote from kxteb0cc on the 2nd floor: I have an idea, use the secondary pop-up menu method


XML/HTML code? 5363738394041424344454647484950515253

Khan. . . . . But thank you anyway

Try the css attribute
text-overflow:ellipsis;

It’s best to write a js to get her~~~

display:block; /*Define as block level*/
overflow:hidden; /*The excess part is hidden. */
white-space:nowrap;/*Replace the non-displayed places with ellipsis...*/
text-overflow:ellipsis;/* Support IE */
-o-text-overflow: ellipsis; /* Supports Opera *
This just allows redundant content to display ellipses within a certain width range, but continuous English letters and numbers are not allowed.
The second question you mentioned is that when you put the mouse over it to display the complete content, use the title. If you still don’t understand, you can send me a private message and I will make a demo for you


If it can help you solve the problem, remember to post and thank you. It’s not easy to earn points.

Luzhu, is it solved?
Please share the code

This can be hidden, and there is...display behind it, but the problem is how to move the mouse above to display the content in the lower right corner of the mouse



Now you can move the mouse up to display it in the lower right. The example is the first and second cells. I hope it will be helpful to you and the people who have the same problem later.

About... This can now be achieved through CSS, text-overflow:ellipsis;
In addition, the title attribute can be used to display the entire content. For example:

This is very simple, let me give you an idea, but I use js to implement it. In fact, just use a question mark expression. When you don’t have the value in td, how many characters need to be displayed, and then use more characters. ... means, for example, you need to have 6 characters in each td and then use... to represent the others, (value.length>6?value.subString(0,6):value), and then you move the mouse Go up and display a layer, and then display what you need on the layer. You can save the things you need in the layer with a hidden layer label. When you want to display it, directly display the image in a mouse move event. Layer is enough. If it is needed for each td, then you will use a span tag in each td to store the actual value of each td. The actual value of each td will be hidden. When the mouse moves in, you can get it directly after the event is fired. Corresponding to the value of the hidden span tag in td, assign it to the layer to be displayed, and then display the layer to complete the function you want. You can try it. This should solve the situation you mentioned. If so, follow up. The method can be posted.

A few question mark expressions are missing...((value.length>6?(value.subString(0,6) "..."):value))

Question marks There are a few missing expressions...((value.length>6?(value.subString(0,6) "..."):value))

This is called a ternary expression, okay?



Is this called a ternary expression?

It’s just a different name. Deng Xiaoping said that a black cat or a white cat is a good cat if it can catch mice. What do you think?

table is forced not to wrap:
table{table-layout:fixed;} td{overflow: hidden; text-overflow: ellipsis;word-break: keep-all;white-space: nowrap;}
In this way, although the ellipses are displayed, the omitted content in td actually exists. You can use some jQuery tip plug-ins to display it, or you can write your own js

Handsome guy, Why didn’t I see that I was given points? I guess that’s fine

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template