我正在尝试建立一个聚合物网站,我想知道如何在中心设置铁图像元素

时间:2017-10-24 12:28:35

标签: css image polymer alignment polymer-2.x

这是我的代码

<iron-image style="width:500px; height:400px; background-color: lightgray;"
    sizing="cover" preload fade src="images/1.jpg"></iron-image>
<iron-image style="width:500px; height:400px; background-color: lightgray;"
    sizing="cover" preload fade src="images/2.jpg"></iron-image>

这是代码的输出,我试图将其放在中心位置:

Output

1 个答案:

答案 0 :(得分:0)

使用iron-flex-layout

<custom-style>
  <style is="custom-style">
    .flex-center-justified {
      @apply --layout-horizontal;
      @apply --layout-center-justified;
    }
  </style>
</custom-style>

<div class="container flex-center-justified">
  <iron-image style="width:500px; height:400px; background-color: lightgray;"
    sizing="cover" preload fade src="images/1.jpg"></iron-image>
  <iron-image style="width:500px; height:400px; background-color: lightgray;"
    sizing="cover" preload fade src="images/2.jpg"></iron-image>
</div>