Using inspect on the HTML doesn't highlight custom component

我的梦境 提交于 2019-12-11 07:37:38

问题


I'm trying to inspect a simple custom component made in Ionic 3. When i inspect it, chrome doesn't highlight the area of the custom component. It only highlights the area if i select a element inside the custom component.

To help u understand it better i've put screenshots of the problem im facing.

The picture shows a div element inside the custom element star-rating, which is being highlighted. This is okay.

But now when i select star-rating element(which is the custom component) , it doesn't highlight anything as you can see in the image below.

[

This is causing a problem when i want to add border to the custom component like this.

star-rating{
    border:1px solid #000;
    border-bottom:0px;
}

resulting in

I could add border in the div tag instead to solve this problem. But i don't want to do that because I want to use this selector for adding css to the last child of star-rating.

star-rating:last-child{
    border-bottom:1px solid #000;
}

回答1:


That's because custom-elements use display: inline by default. You can add the following styles to your component:

:host {
   display: block;
}


来源:https://stackoverflow.com/questions/45693973/using-inspect-on-the-html-doesnt-highlight-custom-component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!