Aligning the text in the header cell of a table

I'm struggling to center align the headers of a table. Below is the HTML code for the table:

<div class="table-responsive">

  <table class="table">

  <thead>

    <tr>
      <th>Photo</th>
      <th>Description</th>
      <th>Location</th>
      <th><span class="d-none d-md-flex text-center">Disposition</span><span class="d-flex d-md-none mx-auto">Dispo</span></th>
      <th class="text-right">Price</th>
      <th><span class="d-none d-md-flex mx-auto">Match %</span><span class="d-flex d-md-none mx-auto">Match</span></th>
    </tr>

  </thead>

  <tbody id="lisc_recs"></tbody>

  </table>

</div>

The specific column causing issues :

<th><span class="d-none d-md-flex text-center">Disposition</span><span class="d-flex d-md-none mx-auto">Dispo</span></th>

If I remove the responsive display elements inside the , such as span, text alignment can be achieved using .text-center like this:

<th class="text-center">Disposition</th>

Is there a way to center the text inside the span when using d--flex or d--table-cell?

It seems the issue stems from the span consistently spanning the full width of the :

https://i.sstatic.net/OHiio.png

Answer №1

To align content within flexbox elements, it is necessary to utilize either the justify-content or align-items properties, not text-align.

Try using the justify-content-center class from Bootstrap.

Learn more about this topic here

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Bug in Responsive Mega Menu Detected

Hey everyone, I've got a Mega Menu below for you to check out! <div id="menu-wrapper"> <ul class="nav"> <li><a href='#'>Brands</a> <div> <div class="nav-colu ...

Implementing a Vertical Scrollbar for tbody Using Bootstrap Table Styles

My goal is to display a vertical scrollbar within the tbody. After researching, I found suggestions to apply display:block to both the tbody and thead, as shown here Unfortunately, this solution does not work when the table has Bootstrap's table tabl ...

Despite applying a CSS reset in the modal, the margin-bottom property is still being recognized in Chrome but not in Firefox

Here is a snippet of CSS code that I am currently working with: * { margin: 0; padding: 0; } body { overflow-x: hidden; margin: 0; padding: 0; } .modal { display: none; position: fixed; z-index: 1; left: 0; top: 0; right: 0; bott ...

"Text should be like a hidden secret, unseen yet powerful

Greetings! I have created an animation using Jquery However, I am facing an issue where the .text is visible while my info span is appearing and disappearing I need to retain that class in my .alert span In essence, what I am aiming to achieve is to mak ...

Why isn't my HTML list showing up on Firefox mobile browsers?

I am using jQuery mobile version 1.4.2. Here is the code snippet from my page. HTML <ul data-role="listview" class="ui-nodisc-icon ui-alt-icon"> <li><a href="#" >Real Estate in San Jose</a></li> </ul> CSS .ui-list ...

Attempting to change the appearance of Bootstrap4 checkboxes

I am attempting to recreate a custom checkbox design that I found on Codepenhere However, the use of Bootstrap 4 in the rest of my project seems to be interfering with my custom checkbox style. Here is my test version My testhere I have added a .myCheck ...

Unable to create a horizontal navigation bar

After spending a considerable amount of time on this task, I am perplexed as to why the navbar is not aligning horizontally. I have tried various techniques such as floating to the left and using display inline, but nothing seems to be working. Could there ...

Issues with the background-image scroll feature not functioning as intended

Can anyone help me out with a CSS issue I'm having? I've set an image as my background on a webpage and I want it to scroll with the page. Even though I followed some online tutorials, it's still not working for me. It's been a while si ...

"Adding the Whats app share button underneath your Blogger post: A step-by-step guide

Can you help me with adding a Whats App share button below my post? Here is the CSS code on my website: .tl-postShare{text-align:right;} .tl-postShare ul{display:inline-block;} .tl-postShare ul li{margin:0;} .tl-tagnShare{position:relative;overflow:hidde ...

Is it possible to enlarge a Bootstrap datatable row and reveal a subtable underneath?

I am looking to enhance my bootstrap datatable so that it expands after clicking on an icon. Currently, when I expand the table, it displays another table but expands every row at the same time. I need to figure out how to send only the specific 'td&a ...

What is preventing Sublime Text from recognizing my pseudo classes as valid syntax?

I'm attempting to remove the underlines from all the links I've visited on a website. In my CSS file, I added nav li a:visited { text-decoration: none; } The word "visited" appears as white text in Sublime Text, indicating that the syntax ...

Updating code to insert elements into an array/data structure using Javascript

Hey everyone, I'm new to Javascript and I'm trying to make a change to some existing code. Instead of just returning the count of elements, I want to add each of the specified elements to an array or list. Here is the original code from a Seleni ...

Enhance Your Navbar in Bootstrap 3 by Creating Vertically Expanding Links Relative to Brand Image Dimensions

To best illustrate my issue, I will begin with a screenshot of the problem and then explain what I aim to achieve. Here is the current state of my navbar: Currently, the text of the links on the right side is positioned at the top. Additionally, this is h ...

Using @extend with numeric classes in Bootstrap 5: A step-by-step guide

I am looking to migrate some classes from Bootstrap 4 to 5 because some of the Bootstrap classes are no longer usable, especially in utilities. I am using SASS so I can utilize @extend for this process. https://i.sstatic.net/dEDCw.png For classes .text-l ...

Enhance your Highcharts Areaspline chart by adding a hover effect to highlight a column

Having trouble figuring out how to highlight a column on an area spline. I looked into Chartjs and Highcharts but couldn't find any solutions. I want to highlight the x-axis column up to the chart curve. Currently, I'm using Crosshair in my code, ...

What is the best way to add a background image to a div without a fixed height in order for it to span the full width and

I am trying to incorporate a background image into a div element in such a way that it behaves like a background image in the body. I have looked at an example here: http://plnkr.co/edit/gFZZgPmSKMDu3gZEp1H0?p=preview where the width and height adjust ba ...

Display scroll bar on sidebar in Bootstrap 4

Currently, I am trying out a sidebar example using Codeply. The main requirement for me is to implement a functional scrollbar in my sidebar that resembles the one displayed on the w3schools website. The sample uses Bootstrap 4.3.1, and any sug ...

Having trouble changing the style property of the `<div>` element in my JS function within Bootstrap Studio

I am currently utilizing Bootstrap in Bootstrap Studio along with plain JavaScript. One of the challenges I am facing pertains to changing the background color of a <div> element upon selecting a new tab. The objective is to dynamically alter the ba ...

Determining the Price Tag of User Frustration

I am looking to create a calculator that can determine the financial cost of experiencing anger. While I may not be the best at articulating the issue, I will do my utmost to explain it. Users are required to input their age, salary, hours worked per day, ...

The layout is being disrupted by a bug in the nested list div in IE 7

I am currently in the process of creating a website with nested lists in the sidebar. The parent list contains children li elements. Initially, only 4 list items are displayed, and the rest should be hidden with an option to "Show All" above them. Here is ...