Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Implementing table padding with display: flex

Good afternoon. I’m trying to make a page with a logo in it and a table.
For this layout, I use display flex for the wrapper.
However, when using it, the padding of the table disappears during mobile adaptation. How can this be fixed?
Normal display
enter image description here
What am I trying to achieve
enter image description here
What happens with my code
enter image description here

My code

.wrapper
{
    min-height: 100%;
    overflow: hidden;
}

._container
{
    max-width: 1310px;
    margin: 0px auto;
    padding: 0px 45px;
    box-sizing: content-box;
}

.main_section{
    width: 100%;
    display: flex;
}

.table_text table{
    width: 100%;
    display: block;
}

.table_text tbody, 
.table_text th{
    width: 100%;
    display: block;
}

.table_text tbody{
    overflow-x: auto;
}

.table_text tbody tr{
    width: 100%;
    display: table-cell;
}

.table_text td{
    width: 100%;
    display: block;
}

.table__container {
    padding: 0px;
}

.yacheika td{
    padding: 34px 25px;
}
.yacheika th{
    padding: 34px 25px;
    text-align: left;
}

.title {
    text-align: center;
    padding-bottom: 40px;
}
    <div class="wrapper _container">
        <div class="main_section ">
            <div class="header__container ">
                <img src="logo.svg" alt="logo" class="header_img">
            </div>
            <div class="table__container">
                <div class="title">Table name</div>
                <div class="table_text">
                    <table>
                        <tr>
                            <th>header</th>
                            <th>header</th>
                            <th>header</th>
                            <th>header</th>
                            <th>header</th>
                        </tr>
                        <tr>
                            <td>Content</td>
                            <td>Content</td>
                            <td>Content</td>
                            <td>Content</td>
                            <td>Content</td>
                        </tr>
                        <tr>
                            <td>Content</td>
                            <td>Content</td>
                            <td>Content</td>
                            <td>Content</td>
                            <td>Content</td>
                        </tr>
                        <tr>
                            <td>Content</td>
                            <td>Content</td>
                            <td>Content</td>
                            <td>Content</td>
                            <td>Content</td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you use the layout inspector on your web developer tools you’ll see the min-wdith is clamped so it overflows your browser. You can override this by setting min-width:0 in your .table__container rule.

enter image description here

.wrapper {
  min-height: 100%;
  overflow: hidden;
}

._container {
  max-width: 1310px;
  margin: 0px auto;
  padding: 0px 45px;
  box-sizing: content-box;
}

.main_section {
  width: 100%;
  display: flex;
}

.table_text table {
  width: 100%;
  display: block;
}

.table_text tbody,
.table_text th {
  width: 100%;
  display: block;
}

.table_text tbody {
  overflow-x: auto;
}

.table_text tbody tr {
  width: 100%;
  display: table-cell;
}

.table_text td {
  width: 100%;
  display: block;
}

.table__container {
  padding: 0px;
  min-width: 0; /* <--- Added this property */
}

.yacheika td {
  padding: 34px 25px;
}

.yacheika th {
  padding: 34px 25px;
  text-align: left;
}

.title {
  text-align: center;
  padding-bottom: 40px;
}
<div class="wrapper _container">
  <div class="main_section ">
    <div class="header__container ">
      <img src="https://www.fillmurray.com/200/200" alt="logo" class="header_img">
    </div>
    <div class="table__container">
      <div class="title">Table name</div>
      <div class="table_text">
        <table>
          <tr>
            <th>header</th>
            <th>header</th>
            <th>header</th>
            <th>header</th>
            <th>header</th>
          </tr>
          <tr>
            <td>Content</td>
            <td>Content</td>
            <td>Content</td>
            <td>Content</td>
            <td>Content</td>
          </tr>
          <tr>
            <td>Content</td>
            <td>Content</td>
            <td>Content</td>
            <td>Content</td>
            <td>Content</td>
          </tr>
          <tr>
            <td>Content</td>
            <td>Content</td>
            <td>Content</td>
            <td>Content</td>
            <td>Content</td>
          </tr>
        </table>
      </div>
    </div>
  </div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading