0

For a website I'm using Bootstrap Material Design and having a hard time aligning elements in a row (course.name and the course.update, course.delete buttons).

I want them to align vertically with CSS but vertical-align:middle doesn't work. Neither does <tr valign="middle">.

Any help is appreciated.

{% if course_list %}
    <table class="table table-hover">
        <tr>
            <th>Course Name</th>
        </tr>
        {% for course in course_list %}
            <tr>
                <td><a class="text-nowrap" href="{% url "courses.detail" course.id %}">{{ course.name }}</a>
                    {% if course.instructor == user %}
                        <div class="pull-right">
                            {% url 'courses.update' pk=course.id as url %}
                            {% bootstrap_button button_type='link' content='Edit' button_class='btn-warning' href=url %}
                            {% url 'courses.delete' pk=course.id as url %}
                            {% bootstrap_button button_type='link' content='Delete' button_class='btn-danger' href=url %}
                        </div>
                    {% endif %}
                </td>
            </tr>
        {% endfor %}
    </table>

1 Answers1

0

first of all your table is not responsive, to make it responsive do structure like this

<div class="table-responsive">
        <table class="table table-bordered table-striped">
       //rest of your code
         </table>
     </div>

it will make your table responsive and

.table td {
   text-align: center;   
}

or

<td class="text-center">some text</td>

make it center aligned

this.girish
  • 1,296
  • 14
  • 17