How can we stop Vuetify from overwriting Bootstrap3's classes when using treeshaking?

I am currently in the process of transitioning an app from jQuery/Bootstrap3 to Vue/Vuetify. My approach is to tackle one small task at a time, such as converting the Navbar into its own Vue component and then gradually updating other widgets.

Since the navbar is globally loaded on every page, Vuetify's styles are conflicting with Bootstrap3 styles (like .row, etc). I have intentionally opted not to utilize Vuetify's row, container, or similar components, sticking solely to the components listed in my custom vuetify.js setup.

Is there a way to prevent Vuetify's styling from interfering with Bootstrap? I have configured Vuetify with tree shaking and only imported necessary components in my vuetify.js file:

import Vue from 'vue';
import Vuetify, {
  VApp,
  VCheckbox,
  VRadio,
  VSelect,
  VSwitch,
} from 'vuetify/lib';

Vue.use(Vuetify, {
  components: {
    VApp,
    VCheckbox,
    VRadio,
    VSelect,
    VSwitch,
  },
});

const opts = {};

export default new Vuetify(opts);

Then, using Vue.extend, I extend the NavbarApp:

const NavbarAppRoot = Vue.extend(NavbarApp);

Lastly, I incorporate it into my Navbar app along with other elements like this:

new NavbarAppRoot({
  el: navbarAppRootEl,
  store,
  vuetify, // <-- referring to the above vuetify.js
  propsData: {
    lang: config.lang,
  },
  i18n,
});

It is important to note that I am not importing vuetify.min.css anywhere in the codebase.

To illustrate the conflict between Vuetify and Bootstrap, here is a screenshot: https://i.stack.imgur.com/EWXzs.png

Any suggestions on how to prevent Vuetify's styles from taking precedence over crucial Bootstrap3 styles during this transition phase?

Answer №1

Regrettably, the most effective solution in this scenario is the less aesthetically pleasing one. It involves manually applying the same classes that Bootstrap uses after Vuetify has been loaded.

To address this issue, I have created some global .scss files that are loaded post-Vuetify - specifically a vuetify-overrides.scss file that mirrors all of Bootstrap's container, row, col-* classes, and more. While not visually appealing, this approach does work and prevents your styles from becoming disordered.

NOTE: If you have modified any default variables for Bootstrap such as padding, margin, or grid values, then you will need to generate your customized file by inspecting dev tools and manually copying the displayed output. Keep in mind that creating higher-order CSS variables for this file may be necessary if you intend to easily adjust these variables later on!

.container {
  padding: 0 15px;
  margin-right: auto;
  margin-left: auto;
}
@media (min-width: 768px) {
  .container {
    width: 750px;
  }
}
@media (min-width: 992px) {
  .container {
    width: 970px;
  }
}
@media (min-width: 1200px) {
  .container {
    width: 1170px;
  }
}
.container-fluid {
  padding: 0 15px;
  margin-right: auto;
  margin-left: auto;
}
...
(remaining content omitted for brevity)
...

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

Avoiding line breaks when using an :after pseudo element

I am trying to style external links by adding a pseudo :after element right after the link itself, but I'm having trouble getting it to work on the same line. Here is the CSS code I have: a:not([href*="domain"])::after { content: url(data:image/svg+ ...

Slick.js integrated with 3D flip is automatically flipping after the initial rotation

I'm encountering an issue with my CSS3 carousel and 3D flipping. Whenever I navigate through the carousel and flip to the next slide, the first slide seems to automatically flip/flop after completing the rotation. You can see a visual demonstration o ...

Crafting a dynamic inline search form with Bootstrap

My goal is to replicate the design in this image: This is my current progress: ...

Enhance your website design with a custom content scroller using Bootstrap and

Having trouble getting this plugin to work with bootstrap on my website. Does anyone have a solution for this issue? Alternatively, does anyone know of another approach I could take? UPDATE: I managed to fix the problem myself. Add the following code ...

Adjusting AngularJS scroll position based on key presses

I am currently working on an autocomplete feature using AngularJS. I seem to be experiencing a problem with the scrollbar behavior. In the interactive gif provided, you can observe that the scrollbar remains stationary when navigating with the arrow keys. ...

Vue.js: Incorporating a client-side restful router using vue-router and a state manager

Trying to set up a client-side restful api with vue.js and vue-router where route params can be utilized to showcase a subset of a store's data into components. All the necessary data for the client is loaded into the store during initialization (not ...

Why is Google Chrome cutting off parts of my website?

Has anyone encountered the strange rendering issue in Google Chrome? Check out this bug here http://community.mediabrowser.tv/uploads/site_1/126/annoying_rendering_bug.jpg I sometimes experience it when I visit What is causing this issue? Is there a way ...

Using Axios to configure headers in a Vue.js application

Currently, my axios setup looks like this: import axios from 'axios' axios.get(apiObjUrl, { headers: { 'Content-type': 'application/x-www-form-urlencoded', } }) .then(({data}) => { ...

Steps to obtain the precise source code of a webpage

Is there a way to download the exact source code of a webpage? I have tried using the URL method and Jsoup method, but I am not getting the precise data as seen in the actual source code. For example: <input type="image" name="ctl00$dtlAlbums$ct ...

Utilize the data stored in chrome.storage within the Vue.js data

I'm currently developing a Chrome app where I am utilizing Vue.js for the options page. My goal is to retrieve settings from Chrome storage and inject them into the Vue data. However, I am encountering an issue where I am unable to access Vue compone ...

Is there a way to ensure the .header and .nav remain fixed at the top of the viewport?

I'm currently working on keeping the .header and .nav elements fixed in the viewport so they don't disappear from view. What's intriguing is that I'm utilizing FlexBox, but I haven't come across a FlexBox feature that allows me to ...

Adding a dynamic style programmatically to an element created using createElement in Vue: A guide

I have a canvas element that is created programmatically and I am looking to apply a reactive style to it. canvas = document.createElement('canvas') //Apply style this.$refs.parentElement.appendChild(canvas) In a typical scenario, you would u ...

Guide on integrating Vuex into a Vue 2.6.14 project

Initially, I started working on a Vue project without using Vuex. However, upon realizing the necessity of Vuex for the project, I went ahead and added Vuex using npm. Subsequently, I populated a file named store.js with Vuex boilerplate code. Despite the ...

How can I modify a prop within a nested component?

I'm currently working with Vue.js version 2.5 and facing a challenge with a list. Each item in the list has a button that toggles its details. The requirement is such that when one button is clicked, all other details should be closed and only the sel ...

Using the ng-app directive value with HTML and CSS can sometimes cause issues and the styles may not apply

angular.js:38 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.8/$injector/modulerr?p0=mainapp&p1=Error%3A…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.8%2Fangular.min.js%3A19%3A463) <body ng-app=""> It was working fine unt ...

Prevent unnecessary image resizing during parallax scrolling animation

Check out my demonstration where the image scaling results in the margin-top of the parallax wrapper being unable to dynamically adjust. Demonstration: http://jsfiddle.net/KsdeX/12/ .wrapper-parallax { margin-top: 150px; margin-bottom: 60px; } W ...

The background image does not appear to be displaying correctly on GitHub pages

I've encountered an issue where my svgs are not displaying as background-image or background on GitHub pages, even though they work fine locally. I utilized sass as a preprocessor for css, in case that detail is helpful. If anyone has insights on how ...

What is the best way to showcase a category on the thumbnail of a WordPress post?

Hey everyone, I hope you're all having a great day! I need some assistance with a slider I'm creating on my WordPress site. I can't seem to figure out how to display the category of each post that appears in the slider and have it stand out. ...

What is the process for incorporating a full-page blog into a blog preview?

I customized a template, but there is a blog section within the div that I am struggling to replicate. Here is the test website for reference: Below is the HTML code for the blog section: <!-- Blog Start --> <section class="section bg ...

What is the best method for ensuring image orientation is displayed correctly?

When utilizing multer node and express for uploading images to my application, I've noticed that some of the images appear rotated 90 degrees once they reach the client side. What could be causing this issue, and how can I resolve it? Just to clarif ...