[英]CSS of one component is conflicting with another component using angular 12
angular.json角.json
"styles": [
"./src/assets/css/base.css",
"./src/assets/css/dashboard.css",
"src/styles.css"
],
styles.css样式.css
/* You can add global styles to this file, and also import other style files */
@import "~assets/css/base.css";
@import "~assets/css/dashboard.css";
app-routing.module.ts应用程序路由.module.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './component/front/home/home.component';
import { DashboardComponent } from './component/admin/dashboard/dashboard.component';
import { ProfileComponent } from './component/admin/profile/profile.component';
import { PagenotfoundComponent } from './component/front/pagenotfound/pagenotfound.component';
const routes: Routes = [
{ path:'', component:HomeComponent },
{ path:'admin/dashboard', component:DashboardComponent },
{ path:'admin/profile', component:ProfileComponent },
{ path:'**', component:PagenotfoundComponent }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
In the above image I have two module inside component folder ie front
and admin
for front
I have base.css
and for admin
I have dashboard.css
and when I serve ng command the layout of front
folder component disturb but when I remove dashboard.css
from styles.css
then it working fine.在上图中,我在组件文件夹中有两个模块,即front
和admin
用于front
我有base.css
和admin
我有dashboard.css
并且当我提供 ng 命令时, front
文件夹组件的布局会干扰,但是当我删除dashboard.css
从styles.css
然后它工作正常。 Similarly In case of admin folder component.同样在管理文件夹组件的情况下。 So, How can I manage this issue?那么,我该如何处理这个问题呢? Please help me.请帮我。
Thank You谢谢你
Any css
that's imported, or declared, in the global styles.css
is considered global eg last style declared takes precedence在全局styles.css
导入或声明的任何css
都被认为是全局的,例如最后声明的样式优先
You can add the styles to the css
associated with and imported by the components, or else continue using the global styles but add more specific selectors您可以将样式添加到与组件关联并由组件导入的css
,或者继续使用全局样式但添加更具体的选择器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.