10
I need it to be displayed up to a maximum of 5 characters of the contents of each table cell in a specific resolution. I don’t know if there are any Pseudo Elemento
do what I need, something like:
Example:
@media (max-width: 548px) {
p:only-five-letters {
content: IMPRIME;
}
}
Output example:
IMPRI
According to the Snippet
below, there is some way to do this in CSS, or some script that does this?
<!DOCTYPE html>
<html>
<head>
<style>
table tr td {
border: 1px solid #000;
}
</style>
</head>
<body>
<strong>Como está:</strong>
<table>
<tr>
<td> OSe </td>
<td> Status </td>
<td> Garantia </td>
</tr>
<tr>
<td> 75553 </td>
<td> Expedido </td>
<td> Aprovada </td>
</tr>
<tr>
<td> 75552 </td>
<td> Cancelado </td>
<td> Não </td>
</tr>
<tr>
<td> 75551 </td>
<td> Analise </td>
<td> Não </td>
</tr>
</table>
<br>
<strong>Como eu preciso:</strong>
<table>
<tr>
<td> OSe </td>
<td> Statu </td>
<td> Garan </td>
</tr>
<tr>
<td> 75553 </td>
<td> Exped </td>
<td> Aprov </td>
</tr>
<tr>
<td> 75552 </td>
<td> Cance </td>
<td> Não </td>
</tr>
<tr>
<td> 75551 </td>
<td> Anali </td>
<td> Não </td>
</tr>
</table>
</body>
</html>
You will have to bring this data already processed to your
html
or through ajs
you will go through all the elements of yourtable
and reduce the number of characters to 5– Jeferson Almeida
Like, I have them in my database, so when I assemble the table I go through each of them and when I print I print only the first five characters ?
– Marcos Henzel
that’s right, in case you’ll need their full content after?
– Jeferson Almeida
I edited the question, I need it to be done only when it is in a specific resolution
– Marcos Henzel
Yes, so I need to display only 5 characters of them, when they are in a specific resolution, making them fit right on the screen.
– Marcos Henzel
now yes, the ideal is that you do it through a
js
, and in addition you save your original values in an attributedata
, in order to be able to return the original value if the resolution returns to normal, at the moment I have no way to help you in the code, but if no one responds until later I help you– Jeferson Almeida
Instead of limiting the characters you have tried to limit the size of the cell using
max-width
. It wouldn’t be 100% but it would be more practical than going through all the values to limit them one by one– Leonardo Rodrigues
I’ll try to do with
JS
, but you say, limit the width of each column?– Marcos Henzel
In this case it would limit the size of each cell to a point where it would fit on average 5 characters
– Leonardo Rodrigues
I get it, I’ll try to apply ! Thanks !!
– Marcos Henzel