Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I wanted some of my Td (the first two numbers from the bottom) to have "PRICE" and "TOTAL PRICE" name labels next to them when the media screen becomes 787px for example, Price: 20USD and TOTAL PRICE: 40USD. But I couldn't figure out how to do it. If you have any suggestions or ideas, please tell me what to do.

THANK YOU

Here is the code: https://codepen.io/jujuju12/pen/NWYjxoM[^]

What I have tried:

I tried to change the position of Table or TH but it didn't work.
Posted
Updated 20-Jul-22 3:54am

You could add a <span> in the <td> and have that become visible/hidden depending on the maximum width of the screen. For example:

CSS
.only-when-small {
  display: none;
}

@media (max-width: 787px) {
  
  .only-when-small {
    display: inline-block;
  }
}

HTML
<td>
  <span class="only-when-small">Price: </span> 20 USD
</td>
 
Share this answer
 
Comments
Member 15332881 23-Jul-22 20:57pm    
Thank you!
See this section at W3Schools on HTML table layout: HTML Table Headers[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900