Centering Slides Vertically in Slick Carousel with Bootstrap 4 Beta

I have spent approximately 2 hours searching and attempting over 15 solutions, but none of them have been successful. The issue involves a slick-slider structured as follows:

<section id="testimonial-section" class="pt-4 pb-0 px-4 bg-dark text-white">
    <div class="container">
        <h2 class="text-center mb-4">Student Evaluations</h2>
        <div class="row">
            <div class="col slide-col">
                <div class="slider">
                    <div>
                        <blockquote class="blockquote text-center">
                            <p class="mb-0">"Text Paragraph 1"</p>
                        </blockquote>
                    </div>
                    <div>
                        <blockquote class="blockquote text-center">
                            <p class="mb-0">"Text paragraph 2."</p>
                        </blockquote>
                    </div>
                    <div>
                        <blockquote class="blockquote text-center">
                            <p class="mb-0">"Text paragraph 3."</p>
                        </blockquote>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

I am in need of a solution where each div without a class is vertically centered within the enclosing slider frame when displayed on the screen. The current layout has these divs positioned at the top of the slider, resulting in unnecessary space at the bottom.

I have experimented with using d-flex on the slider itself along with align-items-center and align-self-center on each div without a class.

Additionally, I have attempted to make the slider display as an inline block and apply the my-auto command to each classless div.

Efforts to use table cell have also been made, but to no avail.

Despite these common suggestions, I am curious if there are any "bootstrappy" methods to quickly resolve this issue. Alternatively, are there any built-in slick-slider features that can address this problem? If not, what is the simplest approach to achieve the desired result?

EDIT: The complete section code is provided above. There is no additional CSS or JS impacting the section. The classless divs and the slider itself have a test1 class to identify any issues, but it has been excluded from this post as it is not part of the final code. The test1 class adds a small red border around the classless div and the slider div directly above it, resulting in the image shown below:

https://i.sstatic.net/H27er.png As depicted, the classless div is pushed against the top of the slider div.

Answer №1

Check out the code on Codepen: https://codepen.io/webdevdani/pen/KXJqKb

If there's space left in your slider, it probably has some height.

Here's a quick and easy solution using Bootstrap4 classes on the slider:

<div class="row">
  <div class="col">
    <div class="slider d-flex justify-content-center align-items-center h-100">
        <div>
          <blockquote class="blockquote text-center">
            <p class="mb-0">"This is a bunch of random works, and each slide is of varying length."</p>
          </blockquote>
        </div>
        <div>
          <blockquote class="blockquote text-center">
            <p class="mb-0">"This is a bunch of random works, and each slide is of varying length.""This is a bunch of random works, and each slide is of varying length."</p>
          </blockquote>
        </div>
        <div>
          <blockquote class="blockquote text-center">
            <p class="mb-0">"This is a bunch of random works, and each slide is of varying length.""This is a bunch of random works, and each slide is of varying length.""This is a bunch of random works, and each slide is of varying length.""This is a bunch of random works, and each slide is of varying length."</p>
          </blockquote>
        </div>
    </div>
  </div>
</div>

In my Codepen example, I added some styling:

.col {
    height: 400px; // Just a random height for this example
}

For more information on Bootstrap flexbox classes, check out the documentation:

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 mouseover in the jQuery area

As I navigate through a WordPress website, I am attempting to create a mandala using dynamic images. Utilizing jQuery and CSS areas, I aim to display the corresponding image when hovering over a specific section. However, I am facing an issue where there ...

The view function is not receiving the dynamic Flask URL variable as expected

Trying to pass a dynamic variable from a Flask route into a view function is causing unexpected behavior. Although this should be a standard feature, the code is displaying odd results. Below is the function in question: @bp.route('/<id>/updat ...

How can I enable two-finger scrolling on mobile web browsers?

I am currently tackling a project that involves dragging operations on a canvas, making scrolling with a single finger impractical. My goal is to enable scrolling using two fingers instead. After testing different touch-action values, I discovered that pi ...

Changing the bootstrap popover location

I'm looking to customize the position of a Bootstrap popover that appears outside of a panel. Here's my setup: HTML: <div class="panel"> <div class="panel-body"> <input type="text" id="text_input" data-toggle="popover ...

The iPhone display scaling issue is causing difficulty viewing the entire website

Currently experiencing difficulties with a page that lacks sufficient content, resulting in a smaller height. As a result, the iPhone is scaling the page and cutting off the full menu bar (960px wide). I attempted to set a minimum height using a media quer ...

What could be causing the misalignment of my select box in Bootstrap framework?

I'm currently trying to replicate the layout of the second image shown below, as seen in the first image. However, I'm facing an issue with the positioning of the selection box and I can't seem to figure out why. I've experimented wit ...

What is the method for incorporating opacity into the background color CSS attribute using a Fluent UI color?

Currently, my challenge involves applying opacity to a background color sourced from the fluent UI library, which utilizes Design Tokens. Typically, I would add opacity to a background color like this: background-color: "rgba(255, 255, 255, 0.5)" However ...

Display Descriptions Upon Hovering Over Images

I am attempting to utilize JavaScript to display the caption of an image only when it is being hovered over, and to have a default caption shown when no image is being hovered. <ul class="logos"> <li class="image-1"></li> <li ...

triggering a button click event in HTML

Below is the creation of a div: <div class="area1"> </div> By using AJAX, I was able to alter the HTML for the aforementioned div with this call: $('#abutton').click(function(e) { e.preventDefault(); ...

Is there a way to ensure that GIFs in jQuery Mobile always start from the beginning?

My cross-platform mobile app built with jQuery Mobile is a small quiz application. After each correct or wrong answer, I display a 3-second GIF. Currently, I have set up the code to show the GIF for 3 seconds before moving on to the next page: else if ($. ...

R code for extracting data without using CSS path

Hey there, I'm reaching out because I'm struggling to figure out how to extract data from a webpage (""). Learning how to scrape data is my current project, and I'm specifically trying to gather contact information (Office, Fax, email) from ...

"Clicking on one item in the Bootstrap submenu doesn't close the other items,

I have this Javascript code snippet that deals with expanding and collapsing submenu items: <script type="text/javascript> jQuery(function(){ jQuery(".dropdown-menu > li > a.trigger").on("click",function(e){ var current ...

Angular component: Placing icons on the right side of a mat-chip element

My mat-chip contains content and a cancel icon, but I am having trouble getting the cancel icon to float to the right consistently. Despite setting a fixed width for the mat-chip, the cancel icon is not aligning properly no matter what CSS techniques I t ...

A guide to aligning text on the right side of an image with HTML and CSS

Looking for assistance to align text on the right side of an image at the same level. Below is the code I have: <a class="following-row" href="index-2.html?pid=2306"> <img alt="Girls logo" src="photos/users/35257/resized/9fd79 ...

Checking for division by zero

I have a question about my calculator. I want to ensure that if the input string contains "0", an error alert is displayed. However, I do not want to check for the "/" character. Below is the function I have written: <input type="text" name="answer" ...

Styling your div elements in CSS to shrink in width relative to their parent container

.container { max-width: 750px; height: 100px; background-color: red; margin: 0; padding: 0; } .box1 { width: 100px; height: 100%; float: left; background-color: black; } .box2 { width: 650px; height: 100%; fl ...

Creating a table with a tableHead cell comprised of multiple components in ReactJS/CSS using Material UI

It's possible that the title lacks description. I am attempting to generate a table with a specific layout like this https://i.sstatic.net/T97C2.gif Essentially, the "Average" cell is combined with two smaller cells for "height" and "width," which c ...

Webpack 5 is unable to load animated gif files

Hello, I am currently diving into webpack and following the official documentation at https://webpack.js.org/guides/asset-management/#setup. My goal is to incorporate an animated gif using webpack 5. Although the placeholder for the gif is loading, I enco ...

Steps to deactivate a JavaScript function once the page has undergone a Page.IsPostBack event

My current setup involves a simple div with the display set to none. Upon page load, I use $("#MyDiv").show(); to display the div after a delay, allowing users to enter information into the form and submit it using an asp.net button. After submitting the ...

Encountering issues with loading tooltips when using Tooltipster alongside ClipboardJS upon clicking

In my project, I am using Bootstrap5, ClipboardJS, JQuery, and Tooltipster. Despite following the initial instructions on the Tooltipster website closely, I am unable to determine what I missed. Here are the two sections, one for the JavaScript scripts an ...