css - 如何有条件地更改 Angular 组件中的样式 url?是否可以?

标签 css angular typescript

<分区>


关闭 3 年前

我有两个 arbaic 布局和 english 布局的 css 文件,所以我想有条件地更改组件中的 styleurl。是否可能 ?

最佳答案

您不能在组件的 styleUrls 属性中放置条件,但您可以使用类似的东西:

.some-class {
  // your css style
}

//  arabic css  overrides
._ar {
   .some-class {
    direction: rtl;
   }
}



<div class="parent" [class._ar]="your_condition">
    <textarea class="some-class">
    </textarea>
</div>

关于css - 如何有条件地更改 Angular 组件中的样式 url?是否可以?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56866433/

上一篇:css - React 样式组件,动画 : invert the position of two divs

下一篇:javascript - ChartJS - 渐变颜色重叠

相关文章:

css - Angular 4 CSS DIV 背景图像绑定(bind)不起作用

Access-Control-Allow-Origin 设置为 * 的 Angular 2 http 请求

由于意外字符 '#' 不在我的源代码中,因此 Angular 服务失败

javascript - json 响应 Angular 2 中的错误字符

html - 页面加载后防止百分比调整大小

javascript - 使用 HTML5 和 CSS 的深色模式开关

html - 试图将 flex 元素对齐到底部,但它们却对齐到文本的第一行

typescript - VSCode - 设置带有 Deno(后端)文件夹和 Vite(前端)文件夹的 monorepo

javascript - 是什么会导致Math.random()在每次重新加载页面时生成相同的 “random”号?

javascript - 将JSON转换为 typescript 中的字符串数组