代码之家  ›  专栏  ›  技术社区  ›  Almas Abdrazak

将样式添加到角度div

  •  0
  • Almas Abdrazak  · 技术社区  · 6 年前

    我没有使用过Angular 2,但我知道css和jquery。

    我无法理解组件内部的语法

    @Component({
        selector: 'sites-stats',
        styleUrls: ['./sites.stats.navbar.component.scss'],
        template: `
    <div [sticky]="{'zIndex': 99}">
    
    </div>
    `
    })
    

    我是说 <div [sticky]="{'zIndex': 99}"> 以这种方式 position: fixed;z-index:99

    我应该搜索什么来理解组件中的这种样式语法?

    顺便说一下,我需要在这个div中添加top,我试过了 <div [sticky]="{'zIndex': 99,'top':'2rem'}"> 但没用

    1 回复  |  直到 6 年前
        1
  •  2
  •   לבני מלכה    6 年前

    您必须按以下步骤操作:

    [style]="{'z-index': '99','top':'2rem'}"
    

    这个电话 style-binding .

    在这里学习: https://coursetro.com/posts/code/24/Angular-2-Class-&-Style-Binding-Tutorial

    在这里: https://alligator.io/angular/style-binding-ngstyle-angular/