2016-08-05 35 views

回答

1

如果使用ViewEncapsulation.None,那麼你可以做這樣的:

@Component({ 
    selector: 'my-component', 
    providers: [], 
    template: ` 
    <div> 
     Hello 
    </div> 
    `, 
    styles: 
    [ 
     'my-component { float:left;width:100%;padding:5px;background:#ccc;}', 
     'html, body {margin:0px; }' 
    ], 
    encapsulation: ViewEncapsulation.None 
}) 

見Plunker這裏:https://plnkr.co/edit/b3jtpO5TAkV4eK0ZuR1k?p=preview

+0

接近,但它是對還是利潤率左右(因爲我的app.component我猜) –

+0

保證金是因爲HTML和BODY標籤需要保證金:0px :) – Delosdos

+0

我已更新答案 – Delosdos

相關問題