Align the content to the center

Currently, I am in the process of creating a profile card view and utilizing Bootstrap to achieve this.

I have set up two div elements - one with the class col-lg-3 and the other with col-lg-9. However, I am facing an issue where the content within col-lg-9 is not centrally aligned. Despite trying various methods like disabling margin and padding, the alignment remains off-center with more space on the right side compared to the left.

The col-lg-9 is nested within a row and a standard container, with the content housed inside it. You can view a sample demonstration on Bootply; by inspecting the container, you'll notice that the contents within the card class have excessive space on the right side.

Below is the HTML code snippet:

<div class="col-lg-9" style="min-height: 100px; background-color: #333">
    <div class="container">
        <div class="card">
            <div class="model-image">
                <img src="img/elliot.jpg">
            </div>
            <div class="card-content">
                <a class="card-header">Team Fu</a>
                <div class="meta">
                    <span class="date">Created in Sep 2014</span>
                </div>
            </div>
            <div class="card-footer">
                <a href="#">ds</a>
            </div>
        </div>
    </div>
</div>

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

I have uploaded the entire site for better visual clarification. Feel free to explore the website for enhanced understanding: demo

Answer №1

To center all .card divs, simply include an additional container:

<div class="wrapper text-center"> 
  <div class="cards-wrapper" style="display:inline-block; box-sizing:border-box;">

    <!-- Insert your .card divs here -->

  </div>
</div>

Remember to apply the appropriate css styles to the cards-wrapper in your stylesheet.

Answer №2

To easily center your elements and their children with bootstrap, simply apply the text-center class to your div.

Instead of placing your CSS in an external stylesheet, consider using inline styles for easier maintenance in the long run.

Answer №3

<div class="content-block align-center">
    <h1 class="header-text">Awesome Team</h1>
    <div class="information">
    <p class="date-info">Established in September 2014</p>
</div>

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

Executing a jQuery event after a div's background-image has finished rendering

Greetings and thank you for sparing a moment. I'm curious to know if there exists a method through jQuery to execute a function immediately after a background image in a div has completed downloading and rendering. Imagine you have the following div ...

React Bootstrap Hamburger Menu in Motion

I've been struggling to move my hamburger menu to the right side of the screen. Despite trying various methods like float, shift right, and alignment, the menu stubbornly remains on the left. I've scoured all the Stack Overflow articles on this i ...

The CSS div mysteriously vanishes right before I can trigger the click event

My CSS code looks like this: #searchbar-wrapper input#header-searchbar:focus + #search-dropdown-wrapper { display: block; } The purpose of this code is to make a dropdown visible when a user focuses on a textbox. The default behavior should be th ...

How can you style text with a circular border using CSS?

I'm struggling to locate an example of what I need. My goal is to make a circle around my text using CSS. While I've seen examples of circles with the text inside, in this case, I aim to have a circle surrounding the text. Here's an illustr ...

Are there any strategies to bypass the color limitations in Bootstrap 5?

Recently, I began studying bootstrap through a crash course video tutorial. The developer demonstrated using various predefined color classes like danger, warning, and primary. Curious, I wondered if it would be possible to substitute dark with tomato re ...

Show individual JSON values from a Python response on a webpage using HTML

I have created a webapp using Flask for OCR on documents with layoutlm. The website features an upload system that accepts images and documents, which are then processed by a Python script for OCR. This script returns a JSON response containing field names ...

Is there a way for me to determine if an image is at the top of the screen?

As I scroll, I am looking for a way to hide my menu and trigger other actions when an image reaches the top of the screen. These images span the full width of the page, so they pass through every point on the x-axis. I've attempted using elementFromPo ...

The element <li> is not permitted to be a descendant of the <select> element

Encountering an error when using the native attribute in the Select component: <TextField select value={options.length ? value : defaultValue} SelectProps={{ native: true, }}> Utilizing the material UI Textfield component. validateDOMNe ...

Tips for adding an icon to an image using PHP and CSS

My goal is to create a responsive image gallery where each image has an icon or text that allows me to delete it if necessary. Here is my HTML and PHP code: <?php $sqlimage = "SELECT * FROM images where `id_user` = '".$customer_id."'"; ...

Preventing HTML Theft

Currently, I am in the process of creating a website and one of my main concerns is protecting the code from potential theft. My goal is to implement measures that will prevent users from extracting the code from the site, and trigger an error message if ...

I am unable to view the entire HTML element

i have a pair of div elements first one : text-logo .text-logo { width: 250px; height: 60px; margin: auto; border: 2px solid #07a2a0; border-radius: 15px 50px 15px 50px; margin-top: 100px; ...

Ways to prevent a timeout when the score exceeds 1000

Could someone help me with clearing the interval and resetting the score in my code? It seems to be working fine, but when the score goes over 1000 and I hit reset, it doesn’t reset completely. I've tried placing the clearTimeout functions before e ...

Exploring the differences between SASS and Bootstrap: the battle of mixins versus @extend

Currently utilizing the SASS version of Bootstrap found here. Curious as to whether there are distinctions between using the pre-set mixins versus utilizing SASS's @extend. For example, considering the following: <div class="wrapper"> Some ...

Is it possible to invoke a JavaScript function within a React.js application?

I am currently working on converting an HTML template to React JS. In my JavaScript file, I have defined some functions. However, when I try to call one of these functions in React JS, I encounter an error. 'abc' is not defined no-undef Here ...

What is the best way to completely fill a column with a horizontal HTML list?

When I split a row into two parts using a div, I encounter an issue where a horizontal html list only displays within the area that the div occupies (Col-6). How can I make this html list expand to fill the entire column? <div class="col-6"> ...

Can the @keyframes in CSS3 be modified?

Exploring CSS3 animations has been a fun project for me, and I want to push the boundaries of what is possible. Currently, I have an infinite animation cycle that is working perfectly. However, I'm curious if it's possible to dynamically change ...

Having difficulty setting a value for a tooltip with replaceWith() function

When using jQuery's .replaceWith() method to insert new DOM contents, I noticed that all content gets replaced except for the value of the title. Even though I tried different approaches, the tooltip only displays {{descriptions.title}} instead of the ...

Showing images in array format from database using Laravel

I tried to set up a database for storing images. The URL of the image is successfully stored but in an array format like ["light.jpg"]. However, when I try to display the image from the database, it only shows an image icon and not the actual image. The im ...

Issue with PrestaShop not displaying page content after adding jQuery

After updating to the latest version of Presta Shop, I encountered an issue. When I inserted the following code: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"> jQuery(document).ready(function(){ ...

Optimizing CSS usage within Django: top recommendations

Throughout a 6-month-long project, I have continuously added new URLs. However, I am now encountering an issue when using the extend 'base.html' function on other pages where the CSS overlaps and creates confusion. My question is: What are the b ...