What is the best way to align all the content inside the box I have designed at the center?

Despite my best efforts, the content within the white box refuses to center itself. I've scoured numerous forums for solutions, tweaked the CSS, and attempted various suggestions, but it stubbornly remains in its original position.

Can someone please provide me with guidance on how to resolve this issue? I simply want to understand what mistake I am making and how to rectify it. If additional information is required, feel free to ask :).

Refer to the screenshot below for clarity:

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

This is my HTML code:

<div class="container">
    <div class="wrapped_content container">
        <div class="white_content container">
                <div class="row row-eq-height">
                    <div id="support-form-wrapper" class="col-xs-12 col-sm-12 col-md-8 form-wrapper">
                        <form class="container" id="submissionForm" name="submissionForm"
                              enctype="multipart/form-data" method="post">
                            {{ csrf_field() }}
                            <input type="hidden" name="submissionFormSubmitted" value="yes">
                            <div class="col-md-7 name-container">
                                <div class="name-support-forms">
                                    <div class="form-group" id="name-form">
                                        <p class="form_header center-block">Enter the confirmation code sent to your email.</p>
                                        <input type="text" class="form-control center-block" id="inputNumberConfirm"
                                               placeholder="######" onfocus="onConfirmFocus()">
                                        <span class="subName error">*Required</span>

                                    </div>
                                </div>
                            </div>

                            <div class="col-md-6 submit-btn-wrapper">
                                <div class="form-group">
                                    <button type="submit"
                                            class="d-block mx-auto btn btn-primary"
                                            data-style="zoom-in" data-size="l">Get Temporary Password
                                    </button>
                                </div>
                            </div>

                        </form>
                    </div>
                </div>
            </div>
           </div>
           </div>

Here's my CSS code:

.wrapped_content {
  background-color: #EFF0F1;
  width: 100%;
}

@media (min-width: 768px) {
  .container {
    width: 750px;
  }
}

.container {
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
  width: 100%;
}

.change_pass.center-block {
  color: #717D79;
  font-size: 32px;
  font-weight: 200;
  margin-top: 40px;
  padding-top: 5%;
}

.wrapped_content h1, .white_content.container h1 {
  text-align: center;
}

.center-block {
  display: block;
  margin-right: auto;
  margin-left: auto;
}

h1, .h1 {
  font-size: 36px;
}


.white_content {
  background-color: #fff;
  margin-top: 30px;
  max-width: 55%;
  max-height: 70%;
  margin-bottom: 153px;
  border: 1px solid #C2C4C4;
  height: 100%;
  width: 638.797px;
}

#inputNumberConfirm {
  max-width: 100px;
  float: none;
}

@media (max-width: 684px) {
  .white_content {
    max-width: 100%;
    max-height: 100%;
  }
}

.form_header.center-block {
  color: #717D79;
  font-size: 20px;
  font-weight: 200;
  margin-top: 40px;
}

p {
  margin: 0 0 10px;
}

Answer №1

It seems like you are not utilizing bootstrap correctly, but don't worry, I have fixed it for you. Avoid using the grid system for centering forms.

.wrapped_content {
  background-color: #EFF0F1;
}

.change_pass.center-block {
  color: #717D79;
  font-size: 32px;
  font-weight: 200;
}

.row-eq-height {
  text-align: center;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">

<div class="container">
  <div class="wrapped_content">
    <div class="white_content">
      <div class="row-eq-height">
        <div id="support-form-wrapper" class="col-12 form-wrapper">
          <form class="container" id="submissionForm" name="submissionForm" enctype="multipart/form-data" method="post">
            {{ csrf_field() }}
            <input type="hidden" name="submissionFormSubmitted" value="yes">
            <div class="name-container">
              <div class="name-support-forms">
                <div class="form-group" id="name-form">
                  <p class="form_header center-block">Enter the confirmation code sent to your email.</p>
                  <input type="text" class="form-control center-block" id="inputNumberConfirm"
                  placeholder="######" onfocus="onConfirmFocus()">
                  <span class="subName error">*Required</span>

                </div>
              </div>
            </div>
            <div class="submit-btn-wrapper">
              <div class="form-group">
                <button type="submit" class="d-block mx-auto btn btn-primary" data-style="zoom-in" data-size="l">Get Temporary Password
                </button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>

Answer №2

If you want to center your content, you can try using the code snippet below:

#content-wrapper{
    margin: 0 auto;
    text-align: center;
    width: 800px; // adjust this value based on your needs
}

Answer №3

Implementing Flexbox Display - Example:

    <style>
    .wrapper{
    display:flex;
    justify-content:center;
    align-items:center;
    }
    </style>

    <div class='wrapper'>

<div class='item'></div>
<div class='item'></div>
<div class='item'></div>

</div>

It's important to note that if you include this style in the head element, it may not override other CSS classes used. To ensure it takes precedence, add !important to each property or consider using inline CSS.

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

Is there a method to add HTML code statically rather than in a dynamic environment?

I'm currently in the process of developing a front-end website with no backend code, as I plan to host it on GitHub pages. I feel that adding any additional backend functionality would be unnecessary. Is there a simple method to incorporate common el ...

What is the process for defining `rel="shortcut icon"` on a webpage featuring images?

Is there a way to set rel="shortcut icon" on an image page? For example, when accessing e.g. example.com/food.png I would like to display rel="shortcut icon" on the image page. How can I achieve this? In another PHP page, I have written <link rel="sh ...

Unable to get table borders to display correctly using CSS styling

Can someone lend me a hand with a CSS issue I'm facing? I want to create some CSS "classes" for tables in my form, but I can only get the borders to display correctly on one of the tables. Here is the code I've been using: table.paddedTable tabl ...

What is the proper way to mention JavaScript packages when including them as parameters in Angular elements within HTML?

I was looking to enhance the command to be more authoritative. <div (click)="lastCall(999)">click me</div> My attempt to utilize Number.MAX_SAFE_INTEGER resulted in an error from my computer stating that it wasn't recognized. As a result ...

How can I set the 'force-output' to 'yes' in HTML Tidy?

Operating in a Windows command line environment, I am utilizing HTML Tidy. My goal is to convert certain html files to xml format, despite any errors present. To achieve this, I take the following steps: Create a file named "conf.txt" with the following ...

The challenge of incorporating multiple stylesheets into an express/node/ejs application: encountering the error "Undefined style."

I am working on a project using express, node, and ejs and I want to be able to use different stylesheets for different views. In order to render a specific view with its corresponding style, I have included the following in my app.js file: app.get('/ ...

Deciphering the hierarchy of z-index stacking

I'm feeling a bit puzzled about how to determine the stacking order using z-index. I am struggling to grasp how browsers handle elements with the position property in comparison to those without it. Is there a set rule to establish the stack order o ...

The checkbox system is designed so that if all child checkboxes are chosen, the parent checkbox will automatically become selected as well

view image description hereLet's create a checkbox structure with some specific conditions: When the parent checkbox is selected, all child checkboxes should automatically get selected. If all child checkboxes are unselected, then the parent checkbo ...

Is the text in bold format or not detectable in contenteditable mode?

I am currently working on developing a custom text editor using the built-in contenteditable feature in HTML. I am trying to figure out how to determine whether the selected text is bold or not within the editor. This is what my current setup looks like: ...

Tips on creating hyperlinks for each database entityCreating hyperlinks to individual database entities

I have a database table with three columns and four rows. I am looking to add hyperlinks to each entity in the third column of the table and then display the output. When attempting to print the array values, I used the following code: echo "<td>", ...

Create masterpieces on HTML5 Canvas with the stroke of your mouse

Is there a way to create drawings on an HTML Canvas using a mouse, such as signing or writing a name? Can you provide guidance on how I can achieve this functionality? ...

Tips for arranging divs in CSS grid with grid-template-areas technique

I am attempting to organize similar groups of elements in a grid: #grid { position: absolute; left: 135px; top: 158px; width: 1080px; height: 1035px; display: grid; grid-template-rows: 99px 1fr 1fr; grid-template-column ...

Enhance the appearance of specific tags within the Acts_as_taggable_on tag_list using Bootstrap styling

I've implemented the "acts as taggable on" gem successfully, but I'm facing an issue when trying to style individual tags in the list using a CSS class. Currently, the code I have applies a bootstrap pill style to the entire list instead of each ...

Click once to reveal, click twice to conceal the slider

I currently have a web page set up so that a single click on the text displays a slider for selecting a range of values. Now, I want to incorporate a feature where a double click will remove the slider. Below is the HTML code: <!DOCTYPE html> < ...

How to properly align a form with a multi-lined label in HTML and CSS?

I'm looking to create a form label that spans multiple lines and align the inputs with the labels. The goal is for the "Releasse Date" label to display as: Release Date (YYYY-MM-DD): [input box] Here's how it currently looks: https://i.sstatic ...

Traffic signal color transitions without the use of a button

My objective is to have the following code run automatically without the need for user input. It should also execute in a loop instead of running through the sequence only once. I attempted to modify the code, but it either failed to work or altered the sh ...

Scrolling horizontally with visible vertical overflow is causing the contents of an absolutely positioned div to be hidden

Note: I have thoroughly searched related questions on stackoverflow and this is not a duplicate question. In my code, I have a `div` with `overflow-x: scroll`, but I want the content in the `div` to be visible in the `y` direction. The issue I'm faci ...

IE11 Experiencing Overflow Issue with List Item Pseudo Element Numbers

Having a simple unordered list of links and using pseudo elements to generate numbers for the list, I encountered an issue with centering the number vertically within its circle background in Internet Explorer 11. Here is the HTML code: <ul> < ...

Functionality Issue: Submit Button Not Working on Designed Form Select

Through dedication and hard work, I managed to create a customized form with images that display correctly in Firefox, Chrome, and Internet Explorer's compatibility mode. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...

Discover the secret to accessing restaurant menus with Foursquare by utilizing file_get_contents on the designated menu URL

I am encountering an issue with retrieving all the menus for a specific venue ID using the Foursquare API. As a workaround, I have opted to fetch menu details by utilizing 'file_get_contents' from the following menu URL: Snippet of Code : $menu ...