Centering text underneath bootstrap image design

After trying various methods, I still couldn't get the text to display directly below my images in the center. Below is the code I attempted:

<div class="our_partners">
        <div class="container">
            <div class="row">
                <div class="col-lg-12 col-md-12">
                    <ul>
                        <li><a href="#"><img src="<?php echo esc_url(wp_get_attachment_url( $image1, 'full' )); ?>" alt=""></a>
                           <span>High Speed Wifi</span> </li>
                        <li><a href="#"><img src="<?php echo esc_url(wp_get_attachment_url( $image2, 'full' )); ?>" alt=""></a>
                          <span>Latest Av Technology</span>

                        </li>
                        <li><a href="#"><img src="<?php echo esc_url(wp_get_attachment_url( $image3, 'full' )); ?>" alt=""></a>
                          <span>Online Booking</span>


                        </li>
                        <li><a href="#"><img src="<?php echo esc_url(wp_get_attachment_url( $image4, 'full' )); ?>" alt=""></a>
  <span>Concierge Service</span>


                        </li>
                        <li><a href="#"><img src="<?php echo esc_url(wp_get_attachment_url( $image5, 'full' )); ?>" alt=""></a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

If you want to view the result, click on the following link:

To see it live, visit this website and scroll down to services:

Answer №1

Displaying images

.our_partners ul li a img {
    padding: 29px 0;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

Change margin-right from 15px to 0;

.our_partners ul li a {
    margin-right: 0;
}

for list items

.our_partners ul li {
    display: inline-block;
    margin: 0px 5px;
}

Additionally,

span {

        display: block;
        text-align: center;
    }

Answer №2

.company_clients ul li a {
    display: block;
    margin: 0 auto;
}

.company_clients ul li a img {
    padding: 12px 0;
    max-width: 100%;
    max-height: 100%;
}
.company_clients ul li a {
    width:220px;
    text-align:center;
} 

Copy and paste this code into your custom stylesheet to ensure proper center alignment.

Answer №3

For optimal spacing between list elements, it is recommended to use the margin-right: 15px property on the list element rather than the anchor element. This approach makes more logical sense as you are separating the list items and not the anchors.

To further enhance this layout, ensure that the span element occupies 100% of the available width and aligns its content in the center.

.our_partners li {
    margin-right: 15px;
}
.our_partners a li span {
    text-align: center;
    display: inline-block;
    width: 100%;
}

Lastly, remember to remove any existing margin settings from the anchor element:

.our_partners ul li a {
    margin-right: 15px;    // <- delete this line
}

Answer №4

To make it easier, you can simply use <br/> like this:

<ul>
  <li>
    <a href="#"><img src="..." alt=""></a><br/>
    <span>High Speed Wifi</span>
  </li>
  (...)

For a cleaner approach, consider treating one of the elements as a block. By default, a, img, and span tags are inline:

<ul>
  <li>
    <a href="#" style="display:block;"><img src="..." alt=""></a>
    <span>High Speed Wifi</span>
  </li>
  (...)

You can also externalize the CSS style by using a class. Another option is to wrap the linked image in a block span:

# foo.css:
span.span-block { display: block; }
...
# 42.html
<span class="span-block"><a ...><img .../></a></span>
...

Answer №5

Insert the text within the <a></a> tag in this way:

<li>
    <a href="#"><img src="...s2-3.png" alt="">
        <span style="display:block;">High Speed Wifi</span>
    </a>
</li>  

MODIFY To make sure all images are properly aligned, you can position the last image as follows:

<li>
    <a href="#"><img src="...cons-2.png" alt="">
        <span style="display:block;">&nbsp;</span>
    </a>
</li>

In addition, it is recommended to apply a specific style to the <span> element in your css stylesheet to minimize repetition.

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

Issue with jQuery Cycle causing images not to load in IE all at once, leading to blinking

When using the jQuery Cycle plugin in IE8 (as well as other versions of Internet Explorer), I am encountering an issue. My slideshow consists of 3 slides, each containing a Title, Description, and Image. The problem arises when viewing the slideshow in I ...

Customize Your Wordpress Category Title with a Background Image

Within my wordpress template, there is a module known as new_boxs. The code snippet below shows that this module displays on the page six times, with two columns wide and three rows down: foreach($data_cat as $cat){ ?> <div class="span6"> ...

Prevent iPhone from automatically changing phone numbers to grey text color

For some reason, the iPhone keeps changing the phone numbers on my site to grey, despite using Drupal 7. I've heard that this is because the iPhone wants to make them stand out for users to interact with. I tried adding the following code to the head ...

What is the best way to display data from an Excel spreadsheet on my website?

I'm faced with a challenge in my Excel spreadsheet- I have a mix of numbers and text that I want to turn into graphical representations on a webpage. I'm considering using Python or PHP to achieve this as HTML alone doesn't seem up to the ta ...

Using JavaScript and HTML to show the current month, date, and year on a webpage

I am looking to display not only the time, but also the month, date and year. My attempted solution involved creating variables for the month, day and year, and then using getElementById. Here is an example of what I tried: var d = date.getDay(); var mn ...

What is the best way to arrange an unordered list in a horizontal layout?

I have four lists that I want to display side by side. The first row should show a Doctor and Patient side by side, the second row should show a Pharma Company and Employee side by side. However, in my code, this layout is not working as intended. .tree ...

I am unable to access the Xml data using VBA's `selectsinglenode` function as it is returning nothing

Below is the XML data: <NewZipCdListResponse> <cmmMsgHeader> <requestMsgId/> <responseMsgId/> <responseTime>20220526:085103847</responseTime> <successYN>Y</successYN> <returnCode>0 ...

Gather data from various HTML elements with JavaScript when submitting a form

How can I extract values from HTML elements and send them for processing through a form? I'm attempting to compile a menu item list with the individual items' structure in place, but I'm struggling to figure out how to fetch the values upon ...

What is the best way to ensure a floated image matches the height of its parent container?

I am facing an issue with setting the height of a logo within a footer div to match the height of the div itself. Using height: 100% doesn't seem to work as expected. Below is the relevant HTML: <footer> <img src="images/circle_logo.png" ...

Simultaneous Activation of Hover Effects on Multiple Elements

I have an array of objects that I'm iterating over. Here is the array: const socialLinks = [ { id: 1, child: ( <> <FaLinkedin className='text-2xl' /> Linkedin </> ), hre ...

Add a flexible element to a container without disrupting the alignment of the other

I'm facing a challenge in adding an action button to the end of a grid layout without affecting the centering of the items. The button should seamlessly fit into the grid, just slightly offset. If you check out my demo, you'll see what I mean. ...

problem with transmitting information through $.ajax

I'm facing a frustrating issue with the $.ajax()... function in my PHP code. I am unable to retrieve the data sent by the ajax request. <?php if ($_POST){ include 'Bdd_connexion.php'; $filiere = $_POST['filiere']; ...

Maximizing spacing for element alignment using space-evenly and :after

I have employed the pseudo-element :after to left-align the last line of a list of blocks, using space-evenly to justify these blocks. However, I am facing an issue where the blocks on the last line do not align properly with the others due to the space ta ...

What is the best way to use jQuery to emphasize specific choices within an HTML select element?

Seeking help with jQuery and RegEx in JavaScript for selecting specific options in an HTML select list. var ddl = $($get('<%= someddl.ClientID %>')); Is there a way to utilize the .each() function for this task? For Instance: <select i ...

How can I programmatically adjust the center of a Google Maps v3 map?

I have a table with 2 columns. The first column contains a div with a Google map, while the second column has a panel that changes its width after a few seconds. On the map, there is a marker placed. Issue: When I click on a button that triggers setCente ...

JavaScript: The functionality of calling functions through buttons ceases to function once the page is updated without reloading

I am trying to create a program that consists of one HTML page, where I can dynamically update and populate it with different elements using JavaScript. The main feature of the program is a button that remains constant in every version and displays a mod ...

Python Selenium for Element Detection

I am a beginner when it comes to using Selenium and I am currently seeking guidance on how to locate the element that is highlighted in this image: Despite my attempts, the following code resulted in an error message being displayed: create_a_detector_b ...

Arrange a pair of div containers side by side on the webpage without the need to alter the existing

Is there a way to align these two div side by side? <div class="main_one"> <div class="number_one">Title A</div> </div> <div class="main_two"> <div class="number_two">Title B</div> </div> <div class=" ...

Creating a simple bootstrap code for developing plugins in Wordpress

After successfully coding in Brackets with the Theseus plugin on my local machine, I encountered a problem when attempting to transfer my code to a Wordpress installation. The transition from Brackets to Wordpress seems far more complicated than expected. ...

Is there a way to maintain scroll position on a dynamically refreshing div?

After searching for hours, I still can't find a solution to my problem. I am using a simple JQuery script to refresh a div and display my PHP output in it. $script = " <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery ...