如何设置ng-content的样式 [英] How to style ng-content

查看:107
本文介绍了如何设置ng-content的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在遵循本教程有关包含的内容 https://scotch.io/教程/angular-2-transclusion-using-ng-content

Am following this tutorial on transclusion https://scotch.io/tutorials/angular-2-transclusion-using-ng-content

但是,没有提及如何设置最终替换ng-content的元素的样式.

However there is no mention on how to style elements that end up replacing ng-content.

似乎我只能在/deep/关键字之前定位css中的那些元素,该关键字通常在定位嵌套组件时使用.这样对吗?

It seems that I can only target those element in the css if preceeded by the /deep/ keyword, which is normally used when targeting a nested component. Is this correct?

推荐答案

更新

::slotted,并且可以与ViewEncapsulation.ShadowDom

https://developer.mozilla.org/en -US/docs/Web/CSS/::开槽

原始

::content xxx { ... }可能也可以正常工作,或者:host xxx { ... }也可以.匀场不是非常严格或准确. AFAIK(旧的>>> /deep/)::ng-deep(受SASS支持)和空格当前相同.

::content xxx { ... } might work as well or :host xxx { ... }. The shimming is not very strict or accurate. AFAIK (>>> /deep/ old) ::ng-deep (supported by SASS) and a space do currently the same.

这篇关于如何设置ng-content的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆