How to use Flexbox to center a div within a Bootstrap Carousel

Having some trouble with centering a circular div in the middle of my Bootstrap Carousel using Flexbox. I'd like the carousel background to expand to cover the entire 100vh height and 100% width of the page.

The issue I'm facing is that the circle keeps showing up at the bottom of the page instead of being perfectly centered. While I've tried adjusting the top and margin-top properties for better alignment, I want to utilize Flexbox to achieve precise central positioning. Additionally, the background images never seem to fully cover the page.

Any assistance or guidance on this matter would be truly appreciated

#fullpage {
height:100vh;
width:100%;
}

.vertical-center{
display: flex;
justify-content: center;
align-items: center;
}

.circle{
background-color: #ff9933;
/*   margin-top:-300px; */
z-index: 300;
position: absolute;
height: 480px;
width:480px;
border-radius: 50%;
/*   top:15%; */
}

.process-container {
position: relative;
}

.circle-text {
text-align: center;
color: white;
font-family: 'Muli', sans-serif;
font-weight: 200;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="style.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link href="https://fonts.googleapis.com/css?family=Muli:200,300,400" rel="stylesheet">
    <script src="app.js"></script>
</head>
<body>
  <div id="fullpage">
    <div id="process" class="vertical-center">

      <div id="processCarousel" class="carousel slide" data-ride="carousel">
          <!-- Indicators -->
          <ol class="carousel-indicators">
            <li data-target="#processCarousel" data-slide-to="1" class="active"></li>
            <li data-target="#processCarousel" data-slide-to="2"></li>
            <li data-target="#processCarousel" data-slide-to="3"></li>
          </ol>
        
          <!-- Wrapper for slides -->
          <div class="carousel-inner ">
            <div class="item active ">
              <div class="process-container">
                  <img src="https://images.pexels.com/photos/127673/pexels-photo-127673.jpeg?auto=compress&cs=tinysrgb&h=350" style="object-fit: cover; height:100vh; width:100%;">
                  <div class="vertical-center">
                      <div class="circle vertical-center">
                          <div class="circle-text">
                              <h1>Test</h1>
                              <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Debitis, dolore?</p>
                          </div>
                      </div>
                  </div>
              </div> 
            </div>
        
            <div class="item">
                <div class="process-container">
                    <img src="http://worldlandforms.com/landforms/wp-content/uploads/2015/03/Beach-1024x683.jpg" style="object-fit: cover; height:100vh; width:100%;">
                    <div class="vertical-center">
                        <div class="circle vertical-center">
                            <div class="circle-text">
                                <h1>Test2</h1>
                                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Debitis, dolore?</p>
                            </div>
                        </div>
                    </div>
                </div> 
              </div>
        
              <div class="item">
                  <div class="process-container">
                      <img src="http://www.ucl.ac.uk/european-institute/events/2016-17/Ocean.png" style="object-fit: cover; height:100vh; width:100%;">
                      <div class="vertical-center">
                          <div class="circle vertical-center">
                              <div class="circle-text">
                                  <h1>Test3</h1>
                                  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Debitis, dolore?</p>
                              </div>
                          </div>
                      </div>
                  </div> 
                </div>
          </div>
        
          <!-- Left and right controls -->
          <a class="left carousel-control" href="#processCarousel" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left"></span>
            <span class="sr-only">Previous</span>
          </a>
          <a class="right carousel-control" href="#processCarousel" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right"></span>
            <span class="sr-only">Next</span>
          </a>
        </div>
      </div>
  </div>
</body>

Answer №1

Give this a try for assistance.

#fullpage {
  height:100vh;
  width:100%;
}

.vertical-center{
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    width: 100%;
}

.circle{
  background-color: #ff9933;
  z-index: 300;
  height: 200px;
  width:200px;
  border-radius: 50%;
}

.process-container {
  position: relative;
  height: 100vh;
  width: 100%;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
}

.circle-text {
  text-align: center;
  color: white;
  font-family: 'Muli', sans-serif;
  font-weight: 200;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>"</meta>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="style.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script=>;
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link href="https://fonts.googleapis.com/css?family=Muli:200,300,400" rel="stylesheet">
    <script src="app.js"></script>
</head>
<body>
  <div id="fullpage">
    <div id="process">

      <div id="processCarousel" class="carousel slide" data-ride="carousel">
          <!-- Indicators -->
          <ol class="carousel-indicators">
            <li data-target="#processCarousel" data-slide-to="1" class="active"></li>
            <li data-target="#processCarousel" data-slide-to="2"></li>
            <li data-target="#processCarousel" data-slide-to="3"></li>
          </ol>
        
          <!-- Wrapper for slides -->
          <div class="carousel-inner ">
            <div class="item active ">
              <div class="process-container" style="background-image: url('https://images.pexels.com/photos/127673/pexels-photo-127673.jpeg?auto=compress&cs=tinysrgb&h=350')">
                
                  <div class="vertical-center">
                      <div class="circle">
                          <div class="circle-text">
                              <h1>Test</h1>
                              <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Debitis, dolore?</p>
                          </div>
                      </div>
                  </div>
              </div> 
            </div>
        
            <div class="item">
                <div class="process-container" style="background-image: url('http://worldlandforms.com/landforms/wp-content/uploads/2015/03/Beach-1024x683.jpg')">
              
                    <div class="vertical-center">
                        <div class="circle">
                            <div class="circle-text">
                                <h1>Test2</h1>
                                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Debitis, dolore?</p>
                            </div>
                        </div>
                    </div>
                </div> 
              </div>
        
              <div class="item">
                  <div class="process-container" style="background-image: url('http://www.ucl.ac.uk/european-institute/events/2016-17/Ocean.png')">
                   
                      <div class="vertical-center">
                          <div class="circle">
                              <div class="circle-text">
                                  <h1>Test3</h1>
                                  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Debitis, dolore?</p>
                              </div>
                          </div>
                      </div>
                  </div> 
                </div>
          </div>
        
          <!-- Left and right controls -->
          <a class="left carousel-control" href="#processCarousel" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left"></span>
            <span class="sr-only">Previous</span>
          </a>
          <a class="right carousel-control" href="#processCarousel" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right"></span>
            <span class="sr-only">Next</span>
          </a>
        </div>
      </div>
  </div>
</body>

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

`How can I use JavaScript to display a modal?`

I am currently a student immersing myself in the world of coding, particularly focusing on learning javascript/jquery. In my recent project, I have developed a chess game using RoR and now I am tackling the promotion move. The idea is that when a Pawn piec ...

SweetAlert2 experiencing issues and has ceased functioning in IE11

<html> <head> <meta charset="utf-8"> <title></title> <link rel="stylesheet" type="text/css" href="css/style_index.css"> <script src="js/testjs.js" charset="utf-8"></script> ...

Is it possible to adjust CSS values in a relative manner?

#bar{font-size:14px;} The font size of #bar is set to 14px. #foobar{font-size:$-2px} // Fictional code The font size of #foobar is now 12px. (calculated as 14px - 2px) Is there a way to dynamically alter the value of a selector like this? ...

"Styling with CSS: Create a sleek border-bottom and background effect

I want to add a bottom border and background color on mouse over. Almost there! In the example below, hovering over the span gives an underline. However, I need the underline to display when entering the hyperlink area. a{ text-decoration: none; paddin ...

Comparing the use of visibility: hidden with -webkit-transform: translate3d() within a PhoneGap application

Currently, I am creating a hybrid application using PhoneGap. As part of the design, I have several divs (each representing a page) that I toggle between by changing their visibility in CSS using "visibility: hidden" and "visible". However, I recently ca ...

Is there a way to make my website mirror the exact layout it has on Codepen?

Recently, I started working on a web project on Codepen using Bootstrap 4 and JQuery quick-adds. The results were perfect on Codepen but when I copied the same code to my text-editor and ran it from there, the formatting of the page was completely off. I t ...

Remove any javascript code from the ajax modal when it is closed or hidden

I am in the process of creating a music website that showcases songs along with their lyrics. One of the features I have added is a lyrics button that, when clicked while a song is playing, opens up a modal displaying the live lyrics. Everything works per ...

Ways to extract the directive's value specific to my scenario

I'm currently working on developing a directive for my Angular app, and I need to find a way to pass a value to my controller. Here's what I have so far: controllers.directive('checkBox', function() { return { restrict: &a ...

The transitionend event fails to trigger if there is no active transition taking place

Take a look at this: http://jsfiddle.net/jqs4yy0p/ JS $('div').addClass('switch').on('transitionend', function(e){ alert('end'); }); CSS div { background-color: red; /*transition: background-colo ...

Ensuring the width of a div matches the adjacent containers

I need assistance in creating a form that adjusts its width based on the form fields. The form contains both explanatory text and input fields, each enclosed in a div with inline-block set. The outer div (also using inline-block) should not expand beyond ...

Execute a function in the background, even if the browser has been shut down

Is it possible to run a JavaScript function in the background, even after the user has closed the browser? I know this can be achieved in android apps, but I'm not sure about JavaScript. ...

How can I programmatically define the earliest and latest selectable dates in a date picker within Angular 4?

I am currently working on a task to prevent users from selecting past dates on a date picker. I want to set the minimum date available on the date picker to the current date. Below is the code snippet I am using to achieve this: Component.html <input ...

Tips for utilizing conditional CSS effectively in CakePHP 2.x

I need help translating this code: <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="css/ie7-style.css" /> <![endif]--> into CakePHP. Currently, I am using $this->Html->css('fileName') in the view file an ...

Adding Dynamic Shadow to Bootstrap 4 Card

I've been trying to figure out how I can add an animated shadow effect to a Bootstrap 4 Card. Currently, my Cards are arranged like this: Image of Bootstrap Card My objective is to create an animated shadow around the card similar to the one shown i ...

Enhancing Visuals within XSL+XML Documents

Currently, I am working on a project for one of my classes that involves showcasing film information loaded from an XML document. While researching similar questions, I found the answers to be confusing and the solutions did not yield any results. My goal ...

Add text to a separate div element on a different webpage using jQuery Mobile

Having a list view, upon tapping by the user, there is a transition to a loading page followed by switching to an article page after completion. The issue I am facing is that although the loading works well, I am unable to append content to the div of the ...

Tips for creating responsive Math Latex

Check out this link to my website page. Also, take a look at this other link. While using Bootstrap, I've noticed that all content is responsive except for the equations in the first link and the Matrix multiplication example in the second link towar ...

Content refuses to show up on my social networking website project when Ajax is employed

I've been working on a Social Media website for a major project, and I recently implemented Ajax to load posts. However, I'm facing an issue where the content is not displaying on the index page after implementation. My goal is to load 10 posts a ...

What is the procedure for setting a form field to be null?

Is it possible to configure the <form> element with a designated value for the action attribute? What steps should I take to assign it to null (#), preventing any actual alteration of the page? ...

What is the best way to create a fixed contact form on specific pages?

There is a Contact Form 7 on the webpage that I want to make fixed to the right side. Initially, the form is hidden and only the form button (open) is visible. When clicked, the form should open. ...