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

HTML/CSS : justify – center and align two icons in a cell of a table

His guys,

I have this table with two icons in the last column. I would like that the icons are next to each, align and with a nice space in the cell. What are the parameters required for that ? I tried with justify-content and margin but it stays like that.

Thank you

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

Here is my result :

enter image description here

How can I correct that ?

Here is the code html :

{% block content %}
<link rel="stylesheet" href="{% static 'test15.css' %}">
<div class="upload-app">
     
    <div class="upload-in">
        <h2>Upload</h2>

        <form method="post" enctype="multipart/form-data">
            
            {% csrf_token %}
            {{ form.as_p }}
            <button type="submit">Upload</button>
        </form>

        
        {% if url %}
            <p>Uploaded files : <a href="{{url}}">{{url}}</a></p>
        {% endif %}
    </div> 

    <div class="listfiles">
        <h2>Files Uploaded</h2>

        <table id="customers">
            <tr>
                <th>Filename</th>
                <th>Date</th>
                <th>Size</th>
                <th>Actions</th>
            </tr>

            {% for file in files %}
            <tr>
                <td>{{ file.Filename }}</td>
                <td>{{ file.Uploaded_at | date:'d.m.Y H:i'}}</td>
                <td>{{ file.SizeFile | filesizeformat}}</td>
                <td>
                    <a href="{% url 'download' file.Id %}">
                        <i class='bx bxs-download'></i>
                    </a>

                    <a href="">
                        <i class='bx bxs-file-pdf' ></i>
                    </a>
                </td>

            </tr>
            {% endfor %}
        </table>
    </div>
</div>

{% endblock %}

Here the css :

.listfiles{
    margin-top: 20px;
    border-radius: 12px;
    background-color: #11101d;
    color: #fff;
    transition: all 0.5s ease;
    width: 800px;
    height: 600px;
}

.listfiles h2{
    display: flex;
    justify-content: center;
    font-size : 26px;
    padding-bottom: 20px;
    padding-top: 30px;
    margin-left: 25px;
}

.listfiles #customers{
    border-collapse: collapse;
    width: 100%;
}

#customers td{
    border: 1px solid #ddd;
    padding: 8px;
    font-size: 12px;

}

#customers a{
    color: #fff;
    font-size: 14px;
    justify-content: center; 
    display: flex;
    row-gap: 3px;

}

#customers th {
    border: 1px solid #ddd;
    padding: 8px;
    font-size: 14px;
}

#customers tr:nth-child(even){background-color: #272730b6;}

#customers tr:hover {background-color: rgb(83, 78, 78);}

#customers th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #0a0911;
color: white;
}

>Solution :

Can you please add class to your icon <td class="iconsColumn">

 {% for file in files %}
            <tr>
                <td>{{ file.Filename }}</td>
                <td>{{ file.Uploaded_at | date:'d.m.Y H:i'}}</td>
                <td>{{ file.SizeFile | filesizeformat}}</td>
                <td class="iconsColumn">
                    <a href="{% url 'download' file.Id %}">
                        <i class='bx bxs-download'></i>
                    </a>

                    <a href="">
                        <i class='bx bxs-file-pdf' ></i>
                    </a>
                </td>

            </tr>
            {% endfor %}

Than in your css add flexBox to that class.

.iconsColumn{
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap:1rem
}

https://www.w3schools.com/csS/css3_flexbox_container.asp

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