Utilize Bootstrap 4 classes to center divs horizontally in the container at the top, middle, and bottom

I'm having trouble finding the right way to center the div elements horizontally.

.d-flex.flex-row.justify-content-center
    div.align-self-start
        p Top

    div.align-self-center
        p Middle

    div.align-self-end
        p Bottom

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

Answer №1

Unfortunately, without more specific details in your question, it is challenging to provide a tailored solution. However, you can explore a method for horizontally centering div elements within a flex container by referring to this jsfiddle example.

<div id="parent">
  <div class="centered">Top</div>
  <div class="centered">Mid</div>
  <div class="centered">Bot</div>
</div>
#parent {
  width: 256px;
  height: 256px;

  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
div.centered {
  width: 64px;
  height: 64px;
  background-color: #33ee33;
  align-self: center;
}

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

Troubleshooting problem with hiding options in Jquery Chosen

Utilizing the chosen multiple selection feature, I have encountered an issue where selected options remain visible after being hidden and updated. Here is the code snippet: $("#ddlcodes").find("option[value ='" + codeValue + "']").hide(); $("#d ...

Reading and extracting information from an HTML page using jQuery

My goal is to extract a specific value from an AJAX response that is in HTML format. Below is the AJAX call I am working with: var result = $.ajax({ //datatype : "application/json", type: "POST", url: ddcUrl ...

Is there a way to split each foreach value into distinct variables?

I am looking to assign different variables to foreach values. I have fetched data from an API in JSON format, and then echoed those values using a foreach loop. My goal is to display the echoed value in an input box using JavaScript. I attempted the follow ...

Text that adjusts its size based on the available space between columns within a row

I am currently developing an application using angular and bootstrap, and I have a requirement to insert a link between two columns in the third row of iteration. Here is what I have attempted so far: Html: <div class="container"> <div clas ...

Ways to align a nested list vertically

There are two nested lists: <ul> <li>First item <ul> <li> <a href="#">some item</a> </li> <li> <a href="#">some item</a> <</li& ...

Learn the steps to show VAT following the price in Magento

I'm encountering a bit of difficulty. Our client has requested that the prices displayed on the listing and product pages should not include VAT, which is understandable. However, they also want it to be indicated after the price as '+VAT (£0.00 ...

What is the method for including line numbers alongside a highlighted code section in highligh.js?

I want to ensure that the text rows are aligned perfectly with the numbers in the yellow vertical bar, without causing any issues with the mouse pointer as it moves across the rows. Adjusting margin or padding also affects the position of the mouse pointer ...

Calculating square roots in AngularJS

I'm building a basic calculator using a combination of HTML, CSS, and AngularJS. Overall, everything is functioning correctly, but I’m looking to incorporate a SquareRoot function into the calculator. Here’s a snippet of my code: function _solv ...

Pass the ID to a PHP script to retrieve the image source tag from the database based on the file

I am facing a challenge that I thought would be simple, but despite my efforts to research and experiment, I can't seem to get it right. I have a database that stores image file names, and I need to retrieve the file name based on the ID specified in ...

The parent div has margin and is set to auto, but the child does not fill the entire width at 100%

My goal is to design a menu that spans the entire width of the page with some margin on the left and right sides. Here is the layout: <div class="parent"> <div class="content"> <div class="element"> <a><p ...

"Enhance Your Design With CSS3 Styling for Labels and

HTML <div class="select"> <div> <label for="kitty" class="kitty-label kitty-label-1 l-center"> </label> <input type="checkbox" name="cats" value="1"> <label>Kitty One</label> ...

Guide to Angular Directives: Assigning Attributes to innerHTML

Looking to add attributes to the inner HTML myTemplate.html <div class="custom-template"></div> HTML <template></template> directive app.directive('template', ['$compile', function($compile) { retur ...

Looping through elements using jQuery in JavaScript

Is there a strange phenomenon happening with my variable in the HTML? I set it to "0", but it displays as "10" on the page. Despite using jQuery and JavaScript, the number stays static at "10" even after refreshing the page. I'm attempting to make th ...

Tap on the link but remain on the anchor

I'm having a problem with my navbar that uses anchors instead of links. Whenever a user inputs something into the chat and hits enter, they get redirected to the first anchor. I believe I need to implement AJAX to resolve this issue, but I'm stru ...

Activate the active tab when clicking on a Bootstrap 4 Collapse navigation tab, both on the page and

Automatically close the active nav-tab when a nav-link is clicked or when a click occurs anywhere on the page. I have attempted changing the removeClass from .tab-pane to various other options such as tabpanel, nav-item, nav-link, and just tab with no suc ...

When the parent element is already set to justify its content with flexbox, you can ensure equal heights for CSS classes by utilizing

Within my design, I have several rows with 3 columns each. Every column contains a main content section labeled SavedSearchBox-content (with various permutations that affect its height) and a footer labeled SavedSearchBox-footer. To structure this layout, ...

Highlighting DOM elements that have recently been modified in Angular

Is there a simple way to change the style of an element when a bound property value changes, without storing a dedicated property in the component? The elements I want to highlight are input form elements: <tr field label="Lieu dépôt"> ...

Is there a way for me to attach a link to a picture displayed in a lightbox that directs to an external ".html" file?

I have a platform where users can view images in a gallery and when they click on an image, it opens up in a lightbox. I am trying to add a feature where the opened image can be clicked again to redirect the user to an external page. I attempted to nest t ...

"Using jQuery to trigger a click event on a specific column within

Welcome to my HTML table. <table id="status_table" class="table table-bordered"> <tr> <th>Serial Number</th> <th>Product Number</th> <th>Description< ...

The fixed positioning isn't functioning properly, here is the code snippet from my CSS and HTML

CSS Code I am not associated with any element that has the CSS property overflow: hidden. <div class="header"> <section class="top"> <div class="links"> &l ...