谷歌聚合物:如何正确地将div放入纸质材料中?

时间:2017-04-05 14:35:07

标签: html css polymer

这是我的代码:



<paper-material elevation="1">
  <p>List of blocks:</p>
  <div class="block">
    <p>Block 1</p>
  </div>
  <div class="block">
    <p>Block 2</p>
  </div>
  <div class="block">
    <p>Block 3</p>
  </div>
  <div class="block">
    <p>Block 4</p>
  </div>
</paper-material>
&#13;
Private Sub Worksheet_Change(ByVal Target As Range)

Dim cell As Range
Dim controlRng As Range, nRng As Range

Set cell = Range("AK9:AR50")
Set controlRng = Range("AF9:AF1000")
Set nRng = Intersect(controlRng, Target)

Application.EnableEvents = False

If Not Application.Intersect(cell, Target) Is Nothing Then
    Select Case Target.Column
        Case 37, 39, 41, 43
            Target.Offset(, 1).Value = Target.Value / Range("V" & Target.Row).Value
        Case 38, 40, 42, 44
            Target.Offset(, -1).Value = WorksheetFunction.RoundUp((Target.Value * Range("V" & Target.Row).Value), -2)
    End Select
End If

If Not nRng Is Nothing Then
    Select Case Target.Value
        Case "No Promotion"
            Target.Offset(0, 1) = Range("M" & Target.Row).Value
        Case "Promotion", "Demotion", "Partner", ""
            Target.Offset(0, 1).ClearContents
    End Select
End If

Application.EnableEvents = True

End Sub
&#13;
&#13;
&#13;

纸质材料元素仅包含&#34;块列表&#34;标签,所有四个div都在外面。如何修复它以使div位于纸质材料元素内?

谢谢。

2 个答案:

答案 0 :(得分:0)

导入iron-flex-layout并将@apply --layout-horiztonal;添加到您的CSS中,该CSS目前相当于

display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-direction: row;
-webkit-flex-direction: row;
flex-direction: row;

答案 1 :(得分:0)

您必须在所有.block div的末尾添加div并设置样式clear: both

内部风格:

.block {
  width: 25%;
  float: left;
 }

.clear {
  clear: both;
}

和纸质材料:

<paper-material elevation="1">
  <p>List of blocks:</p>
  <div class="block">
    <p>Block 1</p>
  </div>
  <div class="block">
    <p>Block 2</p>
  </div>
  <div class="block">
    <p>Block 3</p>
  </div>
  <div class="block">
    <p>Block 4</p>
  </div>
  <div class="clear"></div>
</paper-material>

但这仍然不是最好的解决方案。由于您的纸质材料应具有固定的宽度。此时最好使用display: flex。请注意,较旧的IE不支持flex。因此,如果你真的想支持1%的人,那么你可以继续使用float:left ..但我仍然认为使用display: inline-block会更好。