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

Is there a way to stop Bootstrap from automatically bolding the font?

When testing this simple example without the bootstrap link, everything seems to be working correctly: Hovering over any word changes its color to red, and when hovering away it returns to black. But as soon as the bootstrap link is included, the text bec ...

Tips for creating a submission alert using bootstrap and react.js?

As a newcomer to React.js, I am currently exploring how to implement certain functionality in a form. My goal is as follows: 1) I want to delete the records/inputs after the submit button is clicked. Currently, even after submitting the information and s ...

The appearance of the page varies when viewed on different computers using the same version of Firefox

Previously, I posed a question with a touch of irony regarding Firefox without providing an example. As a result, my question was downvoted and I had to request its removal. Now, I have an example illustrating the issue at hand. It took some time to clean ...

What is the best way to coordinate text and photos within Bootstrap?

Currently, I am working on a bootstrap website that features a slideshow with 3 photos. The jQuery function responsible for this is as follows: $(function () { $.vegas('slideshow', { backgrounds: [{ src: 'img/ph1.jpg ...

Is it possible to use an SVG image as a border with a variable height in CSS

Check out this jsfiddle for my current project's nav setup. I want to center the logo in the middle of the nav with three links centered around it. However, I need the design to be responsive across various screen widths. Any advice on how to achieve ...

How can CSS be utilized to style the visited links that are hovered over

Is there a way to change the font color specifically for visited hyperlinks that are being hovered over by the mouse? I am trying to achieve this: a:visited:hover {color: red} ...

Does Vue.js interfere with classList.remove functionality?

When working with Vue.js, I encountered an issue where elements would briefly flash curly braces to the user before being hidden. To combat this problem, I implemented the following solution: HTML: <div class="main hide-me" id="my-vue-element"> ...

Achieve full height in Grid component of material UI by eliminating margins

In this codesandbox example, I have successfully set the grid container height to full using 100vh. However, there is an issue with a margin of 8px being added by the user agent to the body element, and I'm struggling to find a solution to remove it. ...

What causes the navbar-brand to be hidden on Chrome mobile browsers?

I recently completed building my website at emdashr.com and have been adjusting the mobile views. However, I'm facing an issue where the navbar-brand disappears when viewing the site on mobile Chrome or desktop Chrome with a small viewport. Interestin ...

What methods can I use to achieve a stylish and responsive design for my images?

I have been encountering difficulties styling the images for my website. Despite multiple attempts, I am unable to apply CSS properties such as border-radius and responsive design to the images on my page. The images load fine, but they do not seem to acce ...

Listening for an event or using a CSS pseudo-class to detect when the scrollbar becomes

Are there any JavaScript event listeners or CSS pseudo classes that can detect when a scrollbar appears and disappears? For example, on Mac OS and Windows Internet Explorer 10 or newer, the scrollbars are hidden by default but appear when scrolling begins. ...

Radio buttons are not having the :invalid pseudo class properly applied

Looking to style a radio group with a required attribute. Attempting to adjust the appearance of the radio group depending on whether an input is selected or not. However, it appears that the :invalid pseudo-class does not apply to radio buttons. ...

The height and rows of a textarea element do not adjust properly to the content in FireFox

Looking for a way to create a textarea with dynamic height that adjusts as the user adds new content? The resize property is set to none and overflow is hidden. It seems to be working correctly in Chrome, but Firefox is presenting some mysterious issues wi ...

- Prefixing with -webkit-transform and overlooking z-index

When using Safari 5.1.7 on Windows, I noticed that some rotated elements are overlapping others: However, when I test it on Firefox, Chrome, and IE, the issue doesn't occur: Is there a solution to prevent this overlap problem specifically on Safari? ...

Height of border not being displayed accurately

I have been searching for a solution to my unique issue with inserting borders in HTML and CSS. When I try to add a border to three images, the height does not display correctly. This is all part of my learning process to improve my skills in coding. Belo ...

Displaying a loading screen while a jQuery ajax request is in progress

Currently, I am attempting to display a loading div while waiting for an ajax call to finish. Despite experimenting with various methods, I have not been able to consistently achieve the desired outcome. In my present code, everything functions properly o ...

Strategies for aligning a link on top of another div with absolute positioning

Looking for some assistance with my HTML and CSS code. Specifically, I need the position of the #header id to be set as absolute: <div class="main"> <a href="www.website.com"> <div id="header" class="other"> </div> #heade ...

Why is the column width on this Tumblr page constantly flickering?

Seeking assistance with a minor issue on my Tumblr page - the content column seems to be flickering on mouseover, shifting between full width and its original programmed width. Any insight on the CSS causing this? Much appreciated! Check it out here (Dis ...

I'm still trying to figure out the property position. Why won't my page scroll? (My first time using HTML)

I'm having an issue with my webpage where it doesn't scroll even when the content exceeds the page length. I've tried adjusting the position settings for the body, html, and div elements but haven't seen any changes. Here is the HTML ...

Modifying the CSS class of an element does not produce the desired effect after altering its styles using JavaScript

html: <input id="myinput" class="cinput" type="image" src="http://www.foodwater.org.au/images/triple-spiral-3-small-button.jpg"/> <br><br><br><br> <button id="s">set to visible class</button> <button id="h"> ...