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

Have two HTML form icons in one line without moving content

Current output:

enter image description here

Expected Output:

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

enter image description here

Which is achieved when I do not use forms, here is the current code:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==" crossorigin="anonymous" referrerpolicy="no-referrer"
/>
<table>
  <tr>
    <td>
      <form>
        <button type="submit">
                <i class="fa-solid fa-minus"></i>
            </button>
      </form>
      &nbsp; {{row.2}} &nbsp;
      <form>
        <button type="submit">
                <i class="fa-solid fa-plus"></i>
            </button>
      </form>
    </td>
  </tr>
</table>

Thanks in advance!

>Solution :

Turning your td into a flex container should do the trick. In my example I changed the td to a div and gave it the class contain because the td was dissapearing in the output without the rest of the table.

If you can edit the html, adding a class to that td and using that to target in your css is the best option, if you target the td on its own you will probably affect some other areas of your form that you didn’t intend to

Also, is there a reason you’re using form tags instead of just div to wrap the icon buttons?

.contain {
  display: flex;
  flex-direction: row;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==" crossorigin="anonymous" referrerpolicy="no-referrer"
/>

<div class="contain">
  <form>
    <button type="submit">
            <i class="fa-solid fa-minus"></i>
        </button>
  </form>
  &nbsp; {{row.2}} &nbsp;
  <form>
    <button type="submit">
            <i class="fa-solid fa-plus"></i>
        </button>
  </form>
</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