This article is a mirror article of machine translation, please click here to jump to the original article.

View: 17934|Reply: 0

[Angular] Angular setting component CSS style does not take effect solution

[Copy link]
Posted on 5/6/2020 5:51:23 PM | | | |
clr-datagrid is a third-party datatable component, the component generates a datagrid-style div, I tried setting margin-top doesn't work, the code is as follows:



Using the browser's developer mode, it's okay to add that CSS style.

solution

Angular provides a command ::ng-deep for better compatibility with future tools to force styles to allow intrusion into subcomponents.

CSS is modified as follows:



:host represents a selector that selects the current component.
::ng-deep can ignore the nested hierarchy relationships of the intermediate className. Directly find the className you want to modify.
However, the official documentation says that ng-deep will be abandoned in future versions, and it is unknown what kind of syntax it will become in the future.




Previous:Angular controls the display and hiding of elements
Next:Use JavaScript to access and manipulate databases
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com