-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static Site Generation Issue: CSS Styles Applied Differently Depending on Site Navigation #9325
Comments
@LloydThinks I would guess that this is likely not a result of using a static site but probably due to CSS ordering. If you have multiple CSS rules of the same specificity, the last defined one takes precedence. It's very possible that the ordering of your CSS is different based on which page you load first. Try to narrow it down the appearance difference to a specific class or rule and then see if you can increase the specificity of that CSS rule. |
Hi @danielroe thank you for the advice. I have been hacking away at this issue for the past 3 hours and I've narrowed it down to the use of So again perhaps I can get some clarity: what is different when using the SSG? Can I not expect certain things to work? I'm currently trying to work around this issue by writing my own CSS override mixin, but this is very laborious and perhaps not possible. Lloyd |
I have addressed the issue by removing all Essentially, So, without this Lloyd |
@LloydThinks If you think there is a bug, would you be able to provide a minimal reproduction via https://template.nuxtjs.org ? That would be very helpful, as it is difficult to evaluate without one. |
Are you able to run |
Yes. Just update your |
I'm sorry, but I don't understand how to transition the default build into a {
"name": "codesandbox-nuxt",
"version": "1.0.0",
"description": "Nuxt starter for CodeSandBox",
"author": "Nuxt.js Team",
"private": true,
"scripts": {
"dev": "nuxt generate && nuxt start",
"build": "nuxt generate && nuxt start",
"start": "nuxt generate && nuxt start",
"generate": "nuxt generate && nuxt start",
"post-update": "yarn upgrade --latest"
},
"dependencies": {
"@nuxtjs/tailwindcss": "4.1.2",
"nuxt": "2.15.6"
}
} |
I had to restart the server to force the command to run. Even reloading the webpage did not work. I will keep working at it. |
Alright well I got it to run the Am I missing something? |
You may not see the dist folder but it will exist. Feel free to share a minimal GitHub repo if that's easier for you. |
Alright well I wasn't able to get all the way to producing the bug I wanted, but the sandbox actually get stuck up on another bug. When the static site generator is used, the https://codesandbox.io/s/sweet-saha-gibo6 Lloyd |
@LloydThinks It's not applied because you have a scoped style in the child component that is overriding it (as it occurs later in the CSS): It's normal that dev/production have different orderings of CSS. Again, you shouldn't rely on one component's CSS being loaded 'before' another one. The way to address this is simply to increase the specificity of the CSS you want to take precedence. |
Hi @danielroe,
I think I have a lot more to learn about CSS then. This was unknown to me. I will do some research into the specificity of CSS to improve my laying. Thank you for all your help! |
Versions
Reproduction
No code, I have a question that is hopefully just a misunderstanding about NuxtJS.
Steps to reproduce
Working Example
Broken Example
What is Expected?
I expect that the styling applied to each independent of how you got there. However, it appears that the styling is only properly applied if the user arrives at my site directly to the home page.
What is actually happening?
Styling is not always applied correctly.
Additional Notes
@apply
in the style tags of Vue. This could be the issue but due to the complexity of the Nuxt static site generator, I have no idea how to start looking into this.Any and all help is appreciated. I know I have not posted code or configs, but I think I am misunderstanding something basic about how NuxtJS works, and therefore hoping the issue can be resolve with a couple comments. Otherwise, I can look into making my code public in some way.
Lloyd
The text was updated successfully, but these errors were encountered: