Polymer: Trouble styling the <core-submenu>

雨燕双飞 提交于 2020-01-04 06:04:17

问题


I've created a simple menu inside a <core-drawer-panel> element using <paper-item> with the following:

<paper-item noink>
    <div class="core-menu-item">
        <core-icon icon="maps:beenhere"></core-icon>
        My Places 
    </div>
</paper-item>

As you can see, I've wrapped the insides with a <div> to adjust the icon and text style + positioning. Achieving this effect:

So my question is, how can I style a <core-submenu> in a similar way to achieve the same results?

I've tried following the documentation but styling seems to be very limited in the light DOM; I can only seem to add padding around the whole item, not specifically the icon (for which I'd like to add more padding).

Any suggestions? Thank you.


回答1:


The core-submenu page describes part of the solution. Each core-submenu includes a core-item in its shadow DOM, which is used to display the title and icon for the submenu. You can style this using:

core-submenu::shadow #submenuItem {
  color: red;
}

The item itself contains a core-icon in its shadow root, with an ID of icon, so you can access that using:

core-submenu::shadow #submenuItem::shadow #icon {
  color: blue;
}


来源:https://stackoverflow.com/questions/27771587/polymer-trouble-styling-the-core-submenu

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