“core-header-panel” doesnt seem to work out-of-the-box

人盡茶涼 提交于 2019-12-10 23:46:13

问题


I was trying some core polymer elements, and I have been having trouble using core-header-panel in my demo.

I think the toolbar is right, because I managed to do another demo where it was working with minimal CSS. But all the demo I found for core-header-panel seems to take most of the layout configuration outside the component (Which kinda seems like the point of the component). Did I misinterpret something here?


回答1:


The best pattern today is to use the polymer layout attributes.

<body fullbleed vertical layout>
  <core-header-panel flex>

vertical layout makes the body a (vertical) flex-box, and the flex attribute on the core-header-panel will make it fill the available space. fullbleed attribute sets body to fit the viewport.

This is a better pattern in general than using fit because flex-boxes are more resilient. You could add a different header or footer to body, and the flex panel will adapt.

Also, using layout containers and flex children is a pattern you can continue to use in other places in the application.




回答2:


According to the polymer web site core-header-panel is always needs to have a height set on it explicitly. http://www.polymer-project.org/docs/elements/layout-elements.html

Try using the fit attribute (http://www.polymer-project.org/docs/polymer/layout-attrs.html):

<core-header-panel fit>
  ....
</core-header-panel>



来源:https://stackoverflow.com/questions/24474826/core-header-panel-doesnt-seem-to-work-out-of-the-box

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