What could be causing Nuxt to pull styles from external pages?

In my Nuxt project, I have set up two pages:

|-pages/
|---index.vue
|---login/
|-----index.vue

The index.vue located in the pages directory contains the following styles:

<style lang="scss">

   html,
   body,
   #__nuxt,
   #__layout,
   main {
      height: 100%;
   }

</style>

It is necessary for my container to take up the entire screen height, so the styles cannot be scoped. Everything works fine here, but when I navigate to the /login page, these styles are still being applied inexplicably even after removing the <styles> tag from pages/login/index.vue. This issue perplexes me.

In theory, the styles from pages/index.vue should not affect the /login page 😣

The only workaround I have found is to use the scoped attribute in the style tag of page/index.vue, but this restricts my ability to modify the height of Nuxt's containers.

Do you have any suggestions for a better approach?

Answer â„–1

When you define global CSS styles without scoping them, they will be applied to your entire app.
It's perfectly normal for the styles in login/index.vue to have these properties.

This phenomenon is known as the CSS Cascade.

If you don't want these styles to affect other pages, you can either override the properties in other .vue files (which is okay up to a certain extent) or scope the styles in your root index.vue.

You could also consider using Nuxt layouts if you only want the styles to apply to a specific group of pages.

Keep in mind that height: 100%; is quite a generic property. If you structure your page content normally with HTML blocks stacked on top of each other, you may not need it as it positions them accordingly.
If you encounter any further CSS issues, using your browser's devtools inspector is highly recommended and will help resolve any problems quickly!

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

Looking for assistance in creating an html page with a rotating CSS div containing unordered lists and list items

I am sharing the HTML content of my test page that I am looking to customize similar to some websites I have come across. My goal is to create a rotating div with an unordered list (ul li), where only three divs are displayed at a time while the rest remai ...

The image on the card is barely visible due to the applied Bootstrap 4 styles

When uploading an image with a greater height and narrower width, it may appear distorted in the user cards on the website. Below are the HTML and CSS components used in our Angular framework: HTML <div class="container-fluid" > <div class="ro ...

What is the best way to ensure that the parent div adjusts its width to match the width of its child elements using

I am currently facing an issue with a flex parent div that does not adjust its width to fit the child elements within. How can I resolve this? Essentially, I need to create a dynamic two-dimensional matrix where the user sets the dimensions, resulting in ...

Vue components/code disappearing upon import

I've double-checked the file path and it seems to be correct, but for some reason, the code in App.vue is not displaying. As a newcomer to Vue, I'm a bit lost as to what could be causing this issue. Any guidance or assistance would be greatly app ...

embedding a Rails partial within a .vue component

After some effort, I finally managed to integrate Vue with webpacker in my Rails 4.2.5 application. This is my first experience working on a Vue project and I still have many uncertainties about its usage. I am incorporating Buefy, which consists of Vue.j ...

Changing the background color completely

Need help with CSS! I have two divs, one with a background color of #000 and the other with a transparent PNG image as the background. I want to override the background color with transparency from the PNG file so that the background doesn't cover th ...

Move the electron/vue.js file by dragging and dropping it

Currently, I am developing an application using Electron and Vue.js. One of the features I want to include is a DropZone for files where I only need to retrieve the file path. However, when the file is opened in Electron, it acts like a file viewer inste ...

What is the process for obtaining X through the use of createElement('img')?

Is there a way to retrieve the X position from the left of the tag created using document.createElement('img'); var block00 = document.createElement("img"); block00.src = "images/sep1.png"; If so, how can it be done: if (block00.getBoundingCli ...

Steps to create an HTML list that can be scrolled:

I have designed an HTML list that looks great. However, the issue arises when the list becomes too long - it exceeds the height of the page and there is no scrollbar to navigate through the rest of the list. To address this problem, I need to make the list ...

Generating an interactive Datepicker using Jquery

How can I design a dynamic date picker similar to the image provided below? https://i.sstatic.net/euoNI.png I have attempted to create one, but I am looking for a more interactive date picker. Is there a way to achieve the design shown in the image? The ...

What is the best way to reveal a concealed "div" when hovering the mouse over it?

Currently in the process of developing a dropdown menu to house a search engine form within a static menu bar. The desired functionality is for the search form to appear upon hovering over the "search icon." However, it seems that the submenu fails to disp ...

Ways to achieve text transparency with CSS without converting it to an image

Is there a way to have my navigation bar indicate the selected page by changing the text color and adding a black background, while making only the text inside the current page nav transparent? For example, you can see the effect here: sammarchant.co.uk/n ...

Steps to create a hover effect similar to that of a website (increasing grid size on hover)

Looking to create a hover effect for my boxes similar to the one on this website: I've examined the code of the website above and searched extensively for a similar feature without any luck. Could anyone offer assistance with this, please? ...

Retrieving information from a vuex state array within a different Vue component

Operating a marketplace, I have a need to store selected products from localstorage in the cart within the Vuex Store as a JSON format for sharing with other components. However, when a client makes a purchase, I encounter issues trying to access specific ...

Centering Slides Vertically in Slick Carousel with Bootstrap 4 Beta

I have spent approximately 2 hours searching and attempting over 15 solutions, but none of them have been successful. The issue involves a slick-slider structured as follows: <section id="testimonial-section" class="pt-4 pb-0 px-4 bg-dark text-white"&g ...

Is the focus styling malfunctioning within a React component?

Issue: I'm facing a challenge with my custom search box in a React application. Despite my styling efforts, I can't seem to get the desired outline effect when someone types in the textbox. <div className="search-box"> <Row> & ...

Tips for Customizing the StrongLoop LoopBack Explorer CSS

Our team is currently utilizing Strongloop's LoopBack framework for our REST APIs and we are looking to customize the CSS of the LoopBack Explorer. Unfortunately, it seems unclear which CSS files are being employed (LoopBack vs Swagger) and their exac ...

Instructions on adding an activity indicator in a centered box with a loader inside

I'm currently working on integrating an Activity Indicator into my Vue Native App, but I've been facing some issues as it doesn't seem to be displaying the Activity Indicator properly. Here is the code snippet I've tried: <Absolute ...

Dynamic Vue.js - Changing Backgrounds Based on Mouse Position

Hey there, I'm just starting out with vuejs and I have a question. How can I make the background image move based on the mouse position in vuejs? const el = document.querySelector("#module"); el.addEventListener("mousemove", (e) => { el.style ...

How can you make an element appear when clicking and then disappear with a second click?

Having a bit of an issue here. When I click on the menu button "x," it triggers an onclick event that opens/displays an element. All good so far. But now, I want to click the same menu button "x" to close that same element, and that's where I'm s ...