Nuxt.js: Any way import CSS with scoped

Created on 2 Sep 2017  路  4Comments  路  Source: nuxt/nuxt.js

I put each of the page CSS at bottom of script tag , like example
<style src="~/assets/css/about.css"></style>
but when i route to another page, if the new page element have the same CSS class with previous page element, it will take the previous page CSS, i know put my CSS in style tag with scoped will prevent this case happen, so any way i can import my CSS in style tag with scoped? I tried
<style scoped> @import '~/assets/css/about.css'; </style>
but it not working, any one can teach me how to do it :)

This question is available on Nuxt.js community (#c1392)

Most helpful comment

Hello

In your page, do you try this ?

<style src="~/assets/css/about.css" scoped>

Have a good day ;)

All 4 comments

Hello

In your page, do you try this ?

<style src="~/assets/css/about.css" scoped>

Have a good day ;)

@jleveugle thanks you so much, and may i ask you one more question ? after i check on
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
the style tag with scoped css whether it is not supported on major desktop and mobile browser? :)

Don't be worried, your CSS rules and HTML tag have a uniq data tag. Your CSS rules are prefixed when compiling to impact this template only ;)

You can show the result in your DOM, like this

capture d ecran 2017-09-03 a 13 55 17

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vadimsg picture vadimsg  路  3Comments

bimohxh picture bimohxh  路  3Comments

uptownhr picture uptownhr  路  3Comments

bimohxh picture bimohxh  路  3Comments

pehbehbeh picture pehbehbeh  路  3Comments