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:

https://i.sstatic.net/3ILWS.png

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

Evolution of the material through a fresh new slide

Can someone assist me with an animation issue? I have a slideshow consisting of 4 images that are supposed to transition automatically after a set time interval. Upon initially loading the webpage, the animation works perfectly as intended. However, subs ...

Calibrating height using CSS

Within my HTML document, I have the following structure: <div id="content"> <div id="wrapper"> <div id="steps"> <form id="formElem" name="formElem" action="" method="post"> <fieldset class ...

How to position the play button in the center using Material UI and Flexbox

Seeking advice on achieving a centered play button with borders in this layout. Struggling with flexbox to position the play button within the code provided. function Tasks(props) { const { classes } = props; return ( <div className={classe ...

Trouble with displaying autocomplete options for ajax requests

I recently implemented the autocomplete feature using bootstrap typeahead in my project. The original code snippet worked flawlessly: $(function () { var $input = $(".typeahead"); $input.typeahead({ source: [ {id: "someId1", name: "Display nam ...

Showing nested arrays in API data using Angular

I would like to display the data from this API { "results": [ { "name": "Luke Skywalker", "height": "172", "mass": "77", & ...

Issue with WordPress navigation menu bug

On my website, I have implemented WP nav menu and it seems to be functioning correctly. However, I am facing an issue with the sub link under the home link. The screenshot shows the problem clearly. In the provided image, the "support our work" sub link a ...

Use selenium to locate an element based on its CSS selector

Looking to extract user information from each block using the following code snippet: driver.get("https://www.facebook.com/public/karim-pathan") wait = WebDriverWait(driver, 10) li_link = [] for s in driver.find_elements_by_class_name('clear ...

Unique CSS content for varied designs

I have a CSS code snippet for a tooltip: .GeneralTooltip { background:#c7430f; margin:0 auto; text-transform:uppercase; font-family:Arial, sans-serif; font-size:18px; vertical-align: middle; position:relative; } .GeneralTooltip::before { content:"This is ...

What is the most effective method for transferring data to a concealed input field?

I currently have a webpage with dual forms - one on the main page and another within a Bootstrap modal. The primary form includes fields like "Neck, Chest, Waist," while the modal's form only has an email field. To streamline the submission process, ...

Disappearance of external page upon refreshing - jquery mobile

I'm in the process of developing a jQuery mobile application that loads external pages into a specified div when a link is clicked. These externally loaded pages contain links to additional pages. However, I've noticed that when I click on these ...

What is the best way to implement a sub-menu using jQuery?

After successfully implementing a hover effect on my menu item using CSS, I am now struggling to make the sub-menu appear below the menu item upon hovering. Despite my efforts to search for jQuery solutions online, I have not been successful. Are there a ...

Tips for navigating a user to a different HTML page using JSP code?

In my html page Login.html, I have set up a simple login form with username and password fields, along with a submit button. When the user clicks on the submit button, it triggers a JSP page named Login.jsp to validate the entered credentials against an ...

Can this be achieved using CSS alone, without needing JavaScript?

In this scenario, there is a div with the class of some-class that can have either one or two child div elements. When there is only one child div, I want it to have a width of 100%. However, if there are two child div elements present, I want them to have ...

Manipulating elements with JavaScript to remove them, while ensuring that the empty space is automatically filled

Recently, I decided to enhance my understanding of JavaScript by experimenting with it on various websites. My goal was to use JavaScript to remove the right bar from a webpage and have the remaining body text automatically fill in the space left behind. ...

Send information from Node.js to the webpage and populate designated elements (search by either ID or class) on the webpage

After successfully retrieving data from the mongo database using nodejs, my goal is to display this data on a webpage. function requireUser(req, res, next){ //console.log(req.session.username); if (!req.session.username) { res.redirect('/user_un ...

How can I prevent dataTable resizing?

Is there a solution to prevent datatable resizing? For instance, when the default number of rows per page in the datatable is set to 10 rows. If you input 13 rows into the datatable, it will be divided into 2 pages - with 10 rows on the first page and 3 ro ...

Shadow effect is present under every cell in the table row

I am struggling to create an HTML table with proper vertical spacing between rows and a shadow effect beneath each row. Unfortunately, the shadow always ends up overlapping other table content. I have tried adjusting the positioning of elements and setti ...

What is the best way to populate an HTML array using my AWK script?

In my CGI script written in bash and HTML, I am attempting to display information from multiple CSV files in an HTML array. The following is the script I am using: #!/bin/bash echo "Content-type: text/html" echo "" echo ' <html> <he ...

Do css classes consistently provide a solution to issues with style overrides?

Would it be more beneficial to utilize css .class instead of #id to avoid issues with style overriding and importance? #content ul li a {font-size:10px} #content .demo ul li a {font-size:15px} ...

Using CSS to design a table-like structure with rows that span multiple columns

I am trying to generate a table dynamically using CSS and a JSON array. For example: In the code snippet provided, I have assigned a class of 'spannedrow' to span certain cells in the table, although the class is not defined yet. This is just ...