Nuxt 3 presents challenges with unpredictable CSS behavior

I've noticed a strange issue with my CSS styling.

When I first load or refresh the page, no CSS is applied. However, I found that if I make a change to the style tag - such as adding or removing 'scoped' - the CSS suddenly applies correctly.

My setup includes Nuxt 3.8.1 and I'm using sass for styling.

I've searched online but haven't been able to find anyone else experiencing this exact problem.

Below is an example of the code I'm working with:

<style lang="scss">

@font-face {
  font-family: 'Basil Regular';
  src: url('~/public/Basil-Regular.ttf') format('truetype'),
       url('~/public/Basil-Regular.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
}

  .indexMain{
    margin-top: 0%;
    height:80vh;
    background-image: url('/house3.png');
    background-size: cover;
    background-position: center;

    .headings{
      margin-left: 5%;
      font-size: 2.5rem;
        h1 {
        font-family: 'Basil Regular';
        margin-top: 0%;
        margin-bottom: 0%;
        color: white;
        }
        h3 {
        font-family: 'Basil Regular';
        margin-top: -1%;
        margin-bottom: 0%;
        color: white;
        }
        .first-h1{
            padding-top: 7%;
        }
        .second-h1{
            padding-top: 2.5%;
        }
    }
  }
</style>


<template>
  <div className="indexMain">
    <div className="headings">
        <h1 className="first-h1">Craftsmanship</h1>
        <h3>without compromise</h3>
        <h1 className="second-h1">Efforts </h1>
        <h3>without boundaries</h3>
    </div>
  </div>
</template>

Answer №1

Avoid using the className attribute, opt for the standard class - like this:

<div class="indexMain">
.

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

Optimize your bootstrap carousel for mobile viewing by ensuring that the image and text are

My bootstrap carousel is displaying perfectly on desktop screens with images sized at 1200x400. However, when viewed on mobile devices, the images shrink so much that the text on them becomes unreadable. Additionally, the navigation dots at the bottom of t ...

Class-dependent variable values

I'm trying to figure out how to change a SCSS variable based on a class. Specifically, I want the variable to be green when in the 'dark-mode' class. Css: $test: red; @mixin darkTheme { $test: green; } .theme-dark { @include darkThem ...

jquery's animation causing elements to move abruptly when containing text

For the past hour, I've been grappling with jQuery and could really use some assistance. The following example showcases smooth animations: when you click on either of the divs, the selected div will move left or right if the viewport is wider than 70 ...

What is the best way to align a button within a Jumbotron?

Struggling to find the right CSS placement for a button within a jumbotron. I attempted using classes like text-left or pull-left, but nothing seemed to work as I hoped. I believe a simple CSS solution exists, but it's eluding me at the moment. Ideall ...

What is the process for configuring text on an md-Switch?

I need help setting informational text on an md-switch element from Angular Material design. I want the user to be able to easily understand the current state of a field value. Here is a visual example of what I'm trying to achieve: https://i.sstatic. ...

Tips for aligning a website logo and header vertically with the navbar

I'm having trouble aligning the navbar vertically with my website logo and header. I've tried using display: inline-block; and vertical-align: middle; on the , , and tags within the same div at the top of my website, but it ends up switching fro ...

Is there a method to access the variable name of v-model from a child component in the parent component?

In the scenario below, I am customizing a vue radio component and using the model option to retrieve the v-model value, which is expected to be a string '1'. Is there a way for me to access its variable name 'radio1' in the child compon ...

The compatibility issue between Bootstrap Tab and VueJS 1.0.28 arises when integrated with Vue version 1.0.18, causing malfunctioning

I recently added a feature to my tab-switching functionality that activates tabs based on user actions and backend responses. In HTML: a.nav-link[data-toggle="tab" href="#answered" role="tab" :class="{ active: isActive('answered') }" a.nav-link ...

What does Firefox need in order to fully support Vue.js debugging in PhpStorm?

As per PhpStorm documentation: Debugging Vue.js applications is currently only supported in Google Chrome and other Chromium-based browsers. Despite attempts by individuals like Jonathan Bossenger to make it work with Firefox, the conclusion remains: ...

Creating a website layout using DIV elements that adjusts the background and buttons based on the screen

I'm currently tackling a straightforward HTML page but facing some challenges with the divs. The goal is to have a fullscreen background with four horizontal buttons aligned next to each other at the bottom. These buttons are currently linked to the b ...

Unable to click on the password field using a mouse - encountering a problem on a PHP

The link to access the email admin panel is While I am able to click on the username field, I am unable to click on the password field. The only way to place focus on it is by using the tab button on the keyboard. Initially, everything was functioning co ...

Bootstrap - encompassing or layering columns

I am trying to create a layout where two columns overlap or cover each other. The layout should consist of one column on the left side (6 columns) and one on the right side (6 columns). The desired result is to have: left side (8 columns) and right side ...

The issue with displaying Fontawesome icons using @import in CSS-in-JS was not resolved

I recently changed how I was importing Fontawesome icons: src/App.css @import "@fortawesome/fontawesome-free/css/all.css";` After shifting the @import to CSS-in-Js using emotion: src/App.js // JS: const imports = css` @import "@fortawes ...

Looping through multiple lines of output in VueJS

Looking for a solution to optimize my for loop <div class="w3-panel w3-blue w3-card-4" v-for="peer in peers" v-bind:key="peer" > {{ peer.hop }} {{ peer.time }} </div> ...

Leveraging the :has pseudo-class in Tailwind along with adjacent sibling selectors

My CSS code is working perfectly as intended. [data-type='transfer']:has(+ [data-type^='sale_']) { opacity: 0.25; } This CSS snippet targets elements with data-type="transfer" that are next to elements containing data attri ...

What is the method for creating a shape similar to this using border radius?

To see what I have created so far, click here. <div class="tv">13.3"</div> I am looking to replicate this design exactly. ...

Vue.js routing and mixin dilemma

Calling all Vue developers! I am currently working on a vuebnb tutorial and running into an issue with routing and mixins. I have attempted to assign data before entering the router using the beforeRouteEnter guard, but it seems like my template is being r ...

Using the jquery plugin Sidr in Rails: A complete guide

I've been attempting to integrate the jQuery sidr plugin into my Rails project on Codecademy, but unfortunately, it's not functioning as expected. To view the page, simply click here: If you notice, the menu icon at the top left takes some time ...

Setting up bootstrap for PHP: A step-by-step guide

Struggling with integrating PHP and Bootstrap? I recently attempted to do the same, but unfortunately, my website doesn't seem to recognize Bootstrap. Instead of the sleek Bootstrap design, it's displaying a simple HTML layout. Here's a snip ...

Are there any other potential factors that could lead to CSS files not being located within a Django project?

Apologies for asking the same question repeatedly. Despite trying for several days, I am unable to figure out where I went wrong. Can anyone provide guidance on my issue? I attempted to create a library program using Django. Below is the directory structu ...