Technology Computer Programming

How to make html table all cell in equal height and equal width in all conditions like mobile view and desktop view ?

2 Answers
2 answers

How to make html table all cell in equal height and equal width in all conditions like mobile view and desktop view ?

3
This can be done by giving some fixed widths to table data cells and using absolute position on content.

Here is the CSS:

table {
  width: 90%;
}
td {
  width: 33.33%;
  position: relative;
}
td:after {
  content: '';
  display: block;
  margin-top: 100%;
}
td .content {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: gold;
}

Here is the HTML:


<table>
  <tr>
    <td><div class="content">1</div></td>
    <td><div class="content">2</div></td>
    <td><div class="content">3</div></td>
  </tr>
  <tr>
    <td><div class="content">4</div></td>
    <td><div class="content">5</div></td>
    <td><div class="content">6</div></td>
  </tr>
  <tr>
    <td><div class="content">7</div></td>
    <td><div class="content">8</div></td>
    <td><div class="content">9</div></td>
  </tr>
<table>

Wrote answer · 11/11/2021
Karma · 1435
1

Enter your code here

Wrote answer · 11/12/2021
Karma · 20

Related Questions

How to fix error Argument of type 'MonoTypeOperatorFunction<RouterEvent>' is not assignable to parameter of type 'OperatorFunction<Event_2, RouterEvent>' in Angular?
What is the figure of IPO cycle?
How do robots provide best experience to the customers?
How to use and implement lang attribute and dir attribute in "<td class="sd">Sindhi Text</td>" ? Is It necessary to use span element for this purpose ? What is right way to use lang dir attribute according to w3.org ? Which elements/tag like block and inline etc. support lang dir attribute ?
What is this cow?
The average is called .............. in statistical language?
यथाशक्ती, पाऊसपाणी या सामातजक शब्दाांचा करून प्रकार तलहा (२)?