简体   繁体   English

样式聚合物Web组件

[英]Styling Polymer Web Components

How would you go about styling or refactoring this list, so that the clickable areas of the checkboxes do not interfere with each other? 您将如何设计该列表的样式或重构,以使复选框的可单击区域不会相互干扰? Is there a grouping container I am not aware of? 有我不知道的分组容器吗?

<div layout vertical>
  <div layout horizontal>
    <paper-checkbox></paper-checkbox>
    <paper-item label="item 1"></paper-item>
  </div>
  <div layout horizontal>
    <paper-checkbox></paper-checkbox>
    <paper-item label="item 2"></paper-item>
  </div>
  <div layout horizontal>
    <paper-checkbox></paper-checkbox>
    <paper-item label="item 3"></paper-item>
  </div>
</div>

The checkboxes should be neatly aligned with the paper-item's label (like icons in an icon-button) and of course not interfering with each other or the item. 复选框应与纸张项目的标签整齐对齐(例如图标按钮中的图标),并且当然不会相互干扰或与项目干扰。

So far I didn't have to use any css for my prototype and now checkboxes are breaking everything. 到目前为止,我不必为原型使用任何CSS,现在复选框可以破坏一切。

A little padding does the trick: 一点填充就能达到目的:

<style>
  #container > div {
    padding: 12px;
  }
</style>

<div layout vertical id="container">
  <div layout horizontal center>
    ...
  </div>
  <div layout horizontal center>
    ...
  </div>
  ...
</div>

I've also used the center attribute to vertical align the items on each row. 我还使用了center属性来垂直对齐每行上的项目。

Demo: http://jsbin.com/pobiyawu/1/edit 演示: http : //jsbin.com/pobiyawu/1/edit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM