Struggling to align multiple col-md-10 divs in the center without success

I need help centering a group of articles within a container. I've been using the helper class center-block along with the CSS property float: none; on the container, but it hasn't been working to center the articles. I also tried placing center-block directly inside the col-md-10 article containers, which created an unwanted triangular effect.

Can someone advise me on how to properly center the article divs and point out what I might be doing wrong?

<template>
  <div class="articles">
    <h1 v-text="title"></h1>
    <div v-if="Object.keys(articles).length !== 0" class="center-block">
      <div v-for="article in articles" class="col-md-10 article-border">
        <h1 v-text="article.title"></h1>
        <img :src="article.image" class="pull-left img-responsive margin10 thumb img-thumbnail">
        <p v-text="article.content">
        </p>
        <a class="btn btn-success pull-right marginBottom10" :href="article.url">Continue Reading..</a>
      </div>
    </div>
    <div v-else>No Articles Found!</div>
  </div>
</template>

...

.center-block {
    float: none;
}

Current output:

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

Desired output:

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

JSFiddle: https://jsfiddle.net/rx9ohzg3/1/

Answer №1

To achieve this using the tools provided by Bootstrap, simply utilize the appropriate offset class: Apply the class offset-md-1 to the element that already has col-md-10, allowing it to shift one column to the right and be centered. (With a total width of 12 columns, subtracting 10 for your DIV leaves 2 columns remaining; divide by 2 for equal spacing on both sides results in having 1 empty column at the left)

You can view the outcome in this codepen, which includes the same code as your fiddle but with the addition of the offset class:

https://codepen.io/anon/pen/jaKege

Please note: In Bootstrap 4, the pull-right class for the button has been replaced with float-right, since pull-right is no longer supported.

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

Tips for setting up a Vue.js property as an array type element

To begin, I am looking to initialize the properties of image, description, video, and title with the corresponding fields from the first element in the variants array. The variants array is retrieved by sending an AJAX request that returns a JSON file. ...

Guide to retrieving and editing images from Appwrite using Vue

Currently, I am utilizing a View frontend to retrieve a PDF file from Appwrite Storage. My goal is to acquire the PDF, insert additional text onto it, and then save it to the user's local device. Below is the code I have so far - although I can recei ...

Vue.Js string comparison error

Recently, I started using vue.js and came across an issue while trying to compare two strings in a specific way. Despite my efforts, it seems to be failing in vue. Can anyone provide guidance on how to resolve this problem? This is what I have tried so fa ...

Safari causing misalignment in Bootstrap column layout

I am currently experiencing an issue with the alignment of Bootstrap columns in Safari. Despite being fine on Chrome and IE, the columns appear to be shifted to the right in Safari. https://i.sstatic.net/13Ci4.png https://i.sstatic.net/EiTie.png Below i ...

Custom stylesheet for individual users?

On my website, users can pick a template for their webpage. After selecting a template, I would like them to have the ability to customize certain styles like the font color. Is there a way to achieve this? I was thinking about saving the user's cus ...

Modify the button's border color upon click action

I am looking to implement a feature where the border of a button changes when clicked once and reverts back when clicked again. This should apply individually to each of the 16 buttons with the same class. Additionally, I want to enable the ability to clic ...

Tips for ensuring that the elements within the flexbox are centered and aligned to the left

New proposed layout I need assistance with centering all flexbox items in a 3-column layout. Additionally, I want the items in rows that are not full to be centered and aligned to the left. Any suggestions for achieving this? Below is my current code, bu ...

Tips for fixing the "Uncaught TypeError: Cannot access property 'get' of undefined" error in Vue.JS 2

Here is my component: methods: { reloadMessage() { setTimeout(function () { this.$http.get(window.BaseUrl + '/message/inbox'); }, 1500); } } And here are my routes: Route::group(['prefix' => &ap ...

Button-operated lightbox image slider

I am currently developing a website on WAMP where users can store images and view them in a lightbox effect. I have successfully implemented the lightbox effect, but I am facing challenges with moving between images within the lightbox. <html> <? ...

The width of the Div element is not determined by the parent CSS grid, leading to a lack of ellipsis

I am working on a grid layout where each column contains a div with text. My goal is to have the text show ellipsis when it overflows the column, even though the number of columns is random. I attempted to use the following CSS for the text-containing div ...

What steps can be taken to create a curved bottom for the header section?

While I've seen this question asked before, I'm not satisfied with how the design has been implemented. Here is my desired look for the curved header I've experimented with border radius left and right, but the edges are excessively rounde ...

Steps to assign the identifier as the current index in the v-for iteration

Struggling to assign the id based on the index of a v-for loop. I attempted: <li v-for="(item, index) in items" v-bind:key="item.id"> <p>{{item.name}}</p> <input id= {{index}} type= "number"> < ...

VueJS: Even when disabled, clicking a button can still navigate to a different

Is there a way to prevent the button from being clickable when the current page is the first page? Although the button disables as expected, I'm still encountering an issue where the route changes when it's clicked. Code Snippet (Javascript) ...

What can I do to prevent Masonry from floating all of my grid items to the left?

Is there a way to center justify the masonry grid items? I have noticed that my Masonry layout is aligning all the grid items to the left or justifying them to the left side: <div class="wrap"> <div class="parent grid"> <div class=" ...

Problem encountered while generating a torus shape using webGL

I am currently developing a program that aims to create 3D parametric shapes using webgl. The current code I have works successfully for rendering a sphere, but when I try switching the equations for a torus, only the upper half of the torus is being displ ...

What is the process for adding a Contact Us page to a website?

I recently created a website using html, css and Javascript. I would like to include a 'get in touch' page where visitors can send me messages directly on the site. What steps should I take to make this happen? Is it necessary to set up a databas ...

What is the best way to load my CSS file using express.static?

How do I properly load my CSS file using express.static in Node.js? I have attempted various methods to link my stylesheet to my HTML file through Express, and I'm also interested in learning how to include images, JavaScript, and other assets to crea ...

Do I need to add /public directory to the gitignore file when working with Vue.js

In my Laravel/Vue.js project, I noticed that whenever I make a commit, three additional files are also included: - public/main.js - public/manifest.js - public/vendor.js As a result, I am wondering whether or not I should include the /public folder in the ...

What could be causing my Angular JS application to malfunction?

Presenting myFirstAngularApp.html <html ng-app="store"><!-- The "ng-app" attribute initializes an Angular app. Everything inside this tag is considered part of the Angular app due to ng-app --> <head> <link rel="stylesheet" type= ...

What is the best way to showcase all tab content within a single tab menu labeled "ALL"?

I have created a tab menu example below. When you click on the button ALL, it will display all the tabcontent. Each tab content has its own tab menu. Thanks in advance! function openCity(evt, cityName) { var i, tabcontent, tablinks; tabcontent = doc ...