Steps for designing a fully responsive box-grid featuring 12 identical images with perfectly centered text

I've been struggling for hours trying to solve this problem and I could really use some advice:

My goal is to create a fully responsive grid of equal-sized images (400px x 400px each) with centered text using Bootstrap 3. The grid should span 100% of the screen width, displaying 6 images per row on larger screens with perfect alignment and no gaps or padding. On smaller screens, the image size should scale down responsively and each row should only contain 2 images.

 +--------------------------------------------------------+
 |                     Fixed Navbar                       |
 |--------------------------------------------------------|
 |                                                        |
 |                        Header                          |
 |                                                        |
 +--------+---------+--------+---------+--------+---------+
 |        |         |        |         |        |         |
 |        |         |        |         |        |         |
 |        |         |        |         |        |         |
 |        |         |        |         |        |         |
 +-------------------------------------------------------->
 |        |         |        |         |        |         |
 |        |         |        |         |        |         |
 |        |         |        |         |        |         |
 |        |         |        |         |        |         |
 +--------v---------v--------v---------v--------v---------+
 |                                                        |
 |                                                        |
 |                        Content                         |
 |                                                        |
 |                                                        |
 +--------------------------------------------------------+

The issue I'm facing is that the images are breaking out of the natural 100% row width, creating unnecessary gaps as shown in the picture. This requires scrolling to see the entire page, which is not the intended behavior.

HTML:

<div class="row">

    <div class="col-xs-6 col-sm-2 nopadding">
            <div><img src="../img/image1.jpg" class="img-responsive" alt="Responsive image"></div>
    </div>

    <div class="col-xs-6 col-sm-2 nopadding">
            <div><img src="../img/image2.jpg" class="img-responsive" alt="Responsive image"></div>
    </div>

    ...
 
</div>

CSS:

.nopadding {
    padding-left:0;
    padding-right:0;
}

Answer №1

By default, Bootstrap applies a -15px margin on the right and left of rows and compensates for this with padding on columns. If you need to reset the column padding to zero, remember to also remove the inherent margin applied to rows.

I trust that clears things up for you!

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

The alignment of the Nivo Slider is off-center

Visit to see that the Nivo Slider is not properly centered on the background. I am unsure why this is happening. (Please disregard the 2nd and 3rd pictures as they are not the correct size, but focus on the 1st one). ...

Adding a new row to a table is causing issues with jQuery

var info = [{ "pin": "015-08-0011-000-01", "arp": "015-08-0011-000-01", "tin": "342-432-423-000", "firstname": "John", "middlename": "James", "lastname": "Jones", "suffix": "", "qtr": "1st ...

Converting CSS properties to MaterialUI Styles in ReactJS: A step-by-step guide

In my CSS, I've included the following code: [contentEditable=true]:empty:not(:focus):before{ content:attr(data-text) } This snippet allows me to display a placeholder inside a content-editable div when it is empty. Since I am using Material-UI ...

What is the best way to implement data loading on scroll in HTML with AngularJS?

I'm working with a HTML Dynamic Table <div class="clearfix reportWrapper" > <div class="reportTable"> <table class="table table-bordered footerBGColor"> <thead fix-head class="headerTable"> ...

What is the best way to integrate my company's global styles CDN for development purposes into a Vue cli project using Webpack?

After attempting to import through the entry file (main.js)... import Vue from 'vue' import App from '@/App' import router from '@/router/router' import store from '@/store/store' import BootstrapVue from 'boot ...

"Exploring the differences between an ASP.NET checkbox and an HTML

I have encountered an issue with an HTML checkbox with the ID "notice" in the code behind file. How should I declare it? I have written the code as follows, but it is showing an error that "notice" does not exist in the current context. notifying = ((noti ...

Chrome introduces surprise spacing to text input fields styled uniquely

This particular code snippet is functioning correctly on Firefox, but unfortunately not on Chrome. The height of the input should match the styling of the select, but there seems to be a discrepancy in Chrome. Any ideas on how to rectify this? Upon closer ...

Live server feature in Visual Studio Code is not able to update CSS styles

Here's the problem: I'm encountering a CSS styling issue with the Live Server extension in Visual Studio Code (by ritwickdey). When I launch the live preview, none of my CSS styles are being applied. Although the HTML displays correctly, the CSS ...

Sections overlap, extending the content beyond their designated boundaries

I am facing an issue where the header in the first section remains fixed as an attachment, but when I resize the browser window, the background only covers a small portion of the section. The rest of the content either goes under another section or complet ...

Tips for loading all background images simultaneously

I just created my first website page with a few background images that crossfade. However, I am experiencing an issue where the next background image takes some time to load during the crossfading effect if the page is not cached on the user's comput ...

Conceal Choices During Search using jQuery Select2

I'm having trouble figuring out how to make the Select2 plugin work for my specific color selection feature. My goal is to allow users to choose 5 colors from a list, including an "Other" option. When the user selects "Other", they should be able to ...

Refresh your webpage with new content and modified URLs without the need to reload using window.history.pushState

Hey everyone, I'm looking to incorporate window.history.pushState into my website, but I'm unsure of how to go about it... What I'm aiming for is to have a page dashboard.php and update the URL to dashboard.php?do=edit&who=me, while loa ...

UL tags incompatible with columns

I am attempting to create 2 columns using an ordered list (ul). Despite successfully adding the ul and li's, I am encountering issues with the column formatting. You can view the JSFiddle here. Below is the code snippet: ul { background-color:yello ...

I possess a pair of UI tabs. Whenever a button located outside the tab is clicked, I am required to activate a distinct tab

As a beginner in Javascript, I recently encountered an issue with a UI tab element that contains two tabs. My goal is to create a button that, when clicked, will scroll up and activate the second tab. <style> .tab-container { overflow-x: ...

What is the best way to horizontally center an absolute button within a div?

I'm currently attempting to center an absolute button within a div at the bottom, but unfortunately it doesn't seem to be working as expected. Here is my current approach: .mc-item { background: #F0F0F0; border: 1px solid #DDD; height: 1 ...

Why is the "text-overflow: ellipsis" property of a parent div not functioning properly for its child div?

Why is the CSS property text-overflow: ellipsis not working on a child div with the class name cluster-name? .ft-column { flex-basis: 0; flex-grow: 1; padding: 4px; text-overflow: ellipsis; overflow: hidden; } .ft-column > .cluster-name { ...

Different ways to modify the color and thickness of a variable in HTML5 with either JavaScript or CSS

I am currently working with a JavaScript file where I have a variable defined as follows: var nombre = document.getElementById('nombre').value; The 'nombre' variable corresponds to an element in an HTML file: Nombre: <input type=" ...

Ways to align Material-UI component side by side

My MenuList and Grid components are currently stacked vertically, but I need them to be aligned horizontally. I'm wondering why the Grid is nested within a div in the rendered HTML code. How can I make these components behave more like floating HTML e ...

Conceal elements with a single click of a button

How can I use jQuery to hide all li elements with an aria-label containing the word COMPANY when the Search from documents button is clicked? Here is the HTML code: <ul class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content" id="ui-id-1" t ...

What is the best way to ensure the current tab remains unchanged when updating a page?

I have a unique horizontal tab system displayed as follows: <a id="default" class="link" href="#">Tab 1</a> <a class="link" href="#">Tab 2</a> <a class="link" href="#">Tab 3</a> This tab system is created using basic H ...