Using Bootstrap 3 to implement various grid systems within a single website

For a current project I am working on, my goal is to fill the entire .container with 7 columns within my grid system. To achieve this, I plan on adjusting the Less variable (@grid-columns) before compiling a bootstrap.css file at http://getbootstrap.com/customize/#grid-system.

However, what if I need to revert back to the standard 12 column grid system for another section of the same site?

If I were to create a separate bootstrap.css file while keeping the @grid-columns at 12, I would run into issues when loading it in a browser because it would conflict with the previously created bootstrap.css. This is due to the fact that both files will contain similar class references such as .col-md-7.

I am struggling to find a solution to this problem, but there must be a way to address it, right? Or perhaps I am overlooking something.

Answer №1

One option is to consider utilizing 84 columns in your layout. In this scenario, if you require 7 columns, each column would have a width equivalent to 12 bootstrap columns: 12 12 12 12 12 12 12 = 84

Alternatively, if you need 12 columns, each column should be set to the size of 7 bootstrap columns: 7 7 7 7 7 7 7 7 7 7 7 = 84

This approach can be effective, although it may involve some initial calculations.

If all else fails, resorting to basic math could provide a solution.


Another alternative is to customize the SASS or LESS version of Bootstrap by creating your personalized version. This involves adding classes akin to col-7-xs-.... Upon inspection of the SASS version, I found mixins within the _grid-framework.scss file that are modifiable and usable for integrating your own grid classes effortlessly.

There shouldn't be any reason why this method wouldn't be successful.

Answer №2

Before deciding to implement another grid system for just a couple of instances with 7 columns, consider the approach taken by Bootstrap on their components page http://getbootstrap.com/components/. They creatively use custom CSS without relying on the grid system to create 8 "columns" for icons using an unordered list.

Here's a suggestion:

https://jsbin.com/pofofe/1/

https://jsbin.com/pofofe/1/edit?html,css,output

HTML (comments prevent extra space from inline-block)

 <div class="container">
  <div class="row seven-col">
    
    <div>1</div><!-- do not remove 
    --><div>2</div><!-- do not remove 
    --><div>3</div><!-- do not remove 
    --><div>4</div><!-- do not remove 
    --><div>5</div><!-- do not remove 
    --><div>6</div><!-- do not remove 
    --><div>7</div>
    
  </div>
</div>

CSS:

.row.seven-col {
    text-align: center
}
.row.seven-col > div {
    border: 1px solid red;
    padding-left: 15px;
    padding-right: 15px;
    min-height: 30px;
}
@media (min-width:480px) { 
    .row.seven-col > div {
        display: inline-block;
        width: 50%;
    }
}
@media (min-width:600px) { 
    .row.seven-col > div {
        width: 25%
    }
}
@media (min-width:992px) { 
    .row.seven-col > div {
        width: 14.285%
    }
}

This method reduces the amount of CSS needed compared to adding another grid system solely for a few instances with 7 columns.

NOTE:

The .img-responsive class may not work within inline-block elements or tables with display: table, etc. In such cases, use:

.row.seven-col img {width:100%;height:auto;}

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

AngularJS Toggle Directive tutorial: Building a toggle directive in Angular

I'm attempting to achieve a similar effect as demonstrated in this Stack Overflow post, but within the context of AngularJS. The goal is to trigger a 180-degree rotation animation on a button when it's clicked – counterclockwise if active and c ...

Do CSS Stylesheets load asynchronously?

Is there a difference in how stylesheets are loaded via the link tag - asynchronously or synchronously? In my design, I have two stylesheets: mura.css and typography.css. They are loaded within the head section of the page, with typography.css being load ...

How can jQuery determine the amount of line breaks within a div element?

My div wrap size is a percentage of the screen width, containing multiple .item divs that break into new lines as the window size decreases. I attempted to calculate the total number of boxes that could fit based on their widths compared to the container ...

Understanding the concept of for loops in JavaScript and incorporating them in CSS styling

Hello there! I initially used this code to draw 12 lines, but now I am looking to incorporate a for loop and implement it in CSS. Can someone please guide me on how to proceed? <!DOCTYPE html> <html> <head> <style> #straigh ...

What causes images to unexpectedly expand to fill the entire screen upon switching routes in Next.js?

I'm in the process of creating a website using Next and Typescript, with some interesting packages incorporated: Framer-motion for smooth page transitions Gsap for easy animations One issue I encountered was when setting images like this: <Link&g ...

Navigate quickly to different sections using jump links and adjust the positioning with the style attribute, such as "padding-top

My website incorporates Jump Links to navigate between page elements as part of an interactive User Guide. Everything functions properly on Firefox, IE, and Edge, but Chrome and Opera seem to disregard the 'padding'. Due to a fixed menu bar on t ...

Attempting to connect JQuery to a different page through a data attribute connection

I am currently working on a slider that connects slides from an external page through data attributes. Here is the setup: Main Page <div id="sitewrapper"> <section class="sliderwrapper"> <div id="slider" data-source="slides-pa ...

Troubleshooting problems with resizing images using CSS

I am experiencing an issue with resizing images that I have configured in the admin panel. .users-list>li img { border-radius: 50%; max-width: 100%;    height: auto;     width: 100px;     height: 100px; } When enlarged, the images l ...

Prevent users from clicking by using a CSS class in HTML and JavaScript

,hey there buddy 1° Can you help me figure out how to prevent click behavior using the CSS class? 2° I'm unable to add an ID to the HTML element, so I need to use the Class to achieve this. 3° None of my attempts have been successful so far. El ...

Move a Div to be positioned directly underneath another DIV

There are two DIV elements, one with an absolute position in the lower left corner of the main DIV. The second DIV is hidden and only displayed when clicking on a link. I want the second one to appear just below the first one, but because the first div&ap ...

Click to reveal additional images once the "show more" button is pressed

Hey there! I'm currently working on implementing a feature where, upon clicking "show more", 3 images will be displayed. And if the user clicks again, another set of 3 images will appear, and so on. I seem to be facing some difficulties with the JavaS ...

Problem with CSS creating the Typewriter effect when the third line of text is added

I've been working on a website for my new company and I want to incorporate a typewriter effect on the main page. I came across a tutorial on Medium.com but I'm having trouble adding an additional span to the provided code. Take a look at the lin ...

Is there a way to gradually reveal an element as I scroll to a specific position?

If the window top position is about 100px from the bottom, I want to create a fading in/out effect for the element overlay. Check out this image Any ideas on how to achieve this? .section-card{ position: relative; height: 500px; line-heigh ...

Ways to create a self-contained video viewer

Is it possible to create a self-contained video player similar to jwplayer or the YouTube video player using just HTML, CSS, and JavaScript? I know that I can build a video player by utilizing the video tag along with some custom javascript and css, but ho ...

Python Selenium cannot locate button within an iframe

click here for imageI am trying to interact with the "바카라 멀티플레이" button located at the center of the website. Even after switching into an iframe, I am unable to detect the button. How can I achieve this? from selenium import webdriver im ...

Generating values in a loop - mastering the art of creating data points

My goal is to create a variable within a loop: box-shadow: 835px 1456px #FFF, 1272px 796px #FFF, 574px 1357px #FFFand so on... The concept is simple: box-shadow: x1 y1 #fff, x2 y2 #fff, x3 y3 #fff, x4 y4 #fff ... xn yn #fff. I attempted to achieve this ...

Intercepting 401 with Angular 5 HTTP Interceptor recognizes it as status code 0

One issue I am currently facing is the inability to intercept a 401 status and redirect to the login page, which is a common practice in most applications. My interceptor code seems pretty standard: intercept(request: HttpRequest<any&g ...

Tips on how to align a wrapper-div in the center without affecting the positioning of the

I am looking to keep my page perfectly centered in the browser without affecting the content (similar to how align-text: center works). Specifically, I want to center my wrapper-div. How can I achieve this? Here is a simplified version of my current page ...

Side Menu with Fixed Position Created with Tailwind CSS

Can anyone help me create a social media sidebar that stays fixed on the bottom right side of the screen, regardless of its size? Currently, the sidebar moves when I scroll down, but I want it to remain in place. How can I achieve this fixed positioning? ...

When padding is added on an MVC 5 page, the Bootstrap 4.1.1 class option for rounded-circle becomes distorted

Incorporating VS 2017 and bootstrap 4.1.1 into an MVC 5 page, I am facing a challenge in adding right-side padding to an image without distorting the circular shape of the image, as shown below. When I apply the padding, the circle becomes warped, but remo ...