Guide on centering text vertically in Bootstrap 4

As I begin my journey with Bootstrap, I encountered a challenge while attempting to vertically align text. The issue arises when displaying a modal window from a partial view and trying to showcase an icon and a title in the header:

Below is the page content:

 <div id="actionConfirmation" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="actionModalLabel" aria-hidden="true">
         <div class="modal-dialog">
            <div class="modal-content">
                <div id="partialViewContent"> </div>
            </div>
        </div>
    </div>

And here's the code within the partial view:

<div class="modal-header">
  <div class="row">
    <div class="col-md-2">
        <i class="fa fa-exclamation-triangle fa-2x mx-auto" style="color:red" aria-hidden="true"></i>
    </div>
    <div class="col-md-10">
         <h5 class="modal-title align-middle" id="actionModalLabel">Confirm Denial</h5>
    </div>
  </div>
</div>

The goal is to have "Confirm Denial" centered in the row, but currently it appears bottom-justified alongside the exclamation icon. Despite its perceived simplicity, I'm struggling to achieve the desired alignment.

Answer №1

I finally solved the problem by including:

align-items-center

in the: div class="row"

Answer №2

Just stumbled upon this amazing resource: Mastering vertical alignment

"Elevate the positioning of elements using the vertical-alignment tools provided here. Remember, vertical-align primarily impacts inline, inline-block, and table cell elements."

Pick from .align-baseline, .align-top, .align-middle, .align-bottom, .align-text-bottom, and .align-text-top based on your requirements.

<span class="align-middle">center</span>

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

CSS outline not displaying correctly in latest version of Internet Explorer

Currently delving into the UI of my web design project. I have come across an issue where the outlined feature in a specific div is not displaying properly in IEv11. Below is a snippet of the CSS code causing the problem... .samp-banner:focus, #samp- ...

Creating consistent height for elements in different columns using Bootstrap 5

I'm struggling with keeping the ".item" elements equal height in different columns. Does anyone have a solution for this? <div class="container"> <div class="row"> <div class="col-8"> <h3& ...

Trouble with Javascript slideshow: Incorrect display and malfunctioning

Struggling with implementing a slideshow banner on my webpage, despite following the W3 tutorial. Here is the code I am currently using: HTML: <div class="slide-content" style="max-width:1000px"> <img class="slidepic" src="testheadphoto.jpg" st ...

Which is the preferred method for incorporating images: html or css?

Is it more effective to include images using HTML and specify alt tags, or should they be added through CSS with the text-indent: -9999px property (or a similar technique)? Or does it not make much of a difference? Do search engines interpret the use of t ...

Ensure text is neatly enclosed within bs4 containers

I'm encountering a significant issue with my bs4 boxes that I can't seem to resolve. The primary concern is that when the browser size falls between 600-767.98px and 768-991.98px (as per Dreamweaver), the text within the middle three boxes fails ...

Python's answer to Ruby's LESS gem

I'm excited about the sleekness of the Ruby LESS gem. Currently, I am immersed in a Python/Pylons web project where this tool would be incredibly beneficial. CSS has its flaws, as noted by someone in a recent article we all read with great interest he ...

Creating a series of menu image buttons with rollover effects using HTML and CSS

I am facing an issue with my navigation bar. I have 5 horizontally aligned .png buttons that I want to add rollover effects to using CSS, not Java. After trying multiple solutions, I still can't seem to get it right. None of the methods I attempted w ...

What is the method for centering an input field with inline CSS?

Is there a way to center align an input text box on a webpage using only inline CSS? I have tried various techniques, including the following code snippet, but nothing seems to work: <input type="text" id="myInput" style= "margi ...

Can JavaScript trigger an alert based on a CSS value?

Hello, I am facing an issue. I have created a blue box using HTML/CSS and now I want to use JavaScript to display an alert with the name of the color when the box is clicked. Below is my code: var clr = document.getElementById("box").style.background ...

It appears that the box-shadow feature is malfunctioning on Internet Explorer 8

Hey there, I'm having an issue with the box shadow not displaying correctly in IE 8. Here's my CSS code: .lt-ie9 .imageonHover:hover { box-shadow:1px 1px 5px 5px #E7E0E7; border-radius:3px; zoom: 1; filter: progid:DX ...

What is the best way to position my images next to text using inline-block in CSS?

I'm having trouble aligning images and links side-by-side in my side navigation bar. The images are supposed to show the destination of each link, and I want them to be next to their respective links. I also want the borders of each link to be equal. ...

Tips on moving the first item on the Bootstrap navigation bar to the left side

I have successfully implemented a Bootstrap navigation bar and created a container to display some descriptive text beneath it, as depicted in the image provided. Utilizing the most up-to-date version of Bootstrap has ensured smooth integration. https://i ...

Ways to create a see-through or non-blinking input cursor

Is there a way to make an input caret unwinking or transparent? I am aware of one method to achieve transparency: color: transparent; text-shadow: 0px 0px 0px #000; However, I am curious if there is another approach to accomplish this. ...

Creating a stylish flyout search box using CSS

I am looking to create a search box that pops up when a button is clicked and disappears when clicked outside. My approach involves using CSS to achieve this functionality. Here is the HTML structure I am working with: <div tabindex="0" class="search" ...

I am experiencing some issues with the functionality of the Bootstrap carousel on my website's homepage

I've been working on creating an image carousel with Bootstrap 4, but I'm running into some issues. The images aren't sliding properly, and the cursor to change slides isn't functioning correctly. Additionally, the slides seem to repeat ...

How to create collapsible and expandable HTML table columns using the <th> element?

I've searched far and wide for a solution to this conundrum and come up empty-handed. I have a HTML table with a total of 13 columns. The 7th column, labeled Number of Tops, is a sum of columns 8-11: # Short-sleeve, # Long-sleeve, # Sweaters, # Jacket ...

Why isn't the AngularJS injected view resizing to fit the container?

As a novice delving into a project in the MEAN stack, I'm encountering inconsistent HTML previews. When I view it independently versus running it from the project, the display varies. Here's the intended appearance (in standalone preview): imgu ...

Change background according to URL query

My goal is to dynamically change background images based on a URL parameter, specifically the destination code. With numerous background images available, it's crucial to display the correct one depending on the URL string. For instance, if the URL re ...

Conceal the ::before pseudo-element when the active item is hovered over

Here is the code snippet I am working with: <nav> <ul> <li><a href="javascript:void(0)" class="menuitem active">see all projects</a></li> <li><a href="javascript:void(0)" class="menuitem"> ...

The art of layering images: How to stack one image on top of another

I am in the process of trying to place a logo on top of an image, but I have been unsuccessful so far. Rather than overlapping, the second image is appearing next to the first one. Can you help me figure out how to solve this issue? This is for a website ...