可以使用css3 translateZ()代替z-index吗?

时间:2013-07-31 17:38:19

标签: css css3 css-transforms translate3d

例如,如果将2个div设置为绝对值,则可以通过将第一个div的z-index设置为高于第二个div来将第一个div放在第二个div上。 我们可以使用translateZ()或translate3d来实现这种行为吗?

2 个答案:

答案 0 :(得分:17)

现在,3年之后的答案是,你可以。 您需要在父but it's possible上使用.container { transform-style: preserve-3d; } .test1 { width: 500px; height: 500px; background: red; transform: translate3d(0, 0, 1px); } .test2 { width: 500px; height: 500px; background: green; left: 250px; top: 250px; position: absolute; transform: translate3d(0, 0, 0); }



<div class="container">
  <div class="test1">
    test
  </div>

  <div class="test2">
    test #2
  </div>
</div>
&#13;
Private Sub CmdTransfert_Click()
On Error GoTo Err_CmdTransfert_Click

    Dim Requete As QueryTable

    Dim appXL As Excel.Application
    Dim Classeur As Excel.Workbook
    Dim Cellule As Excel.Range
    Dim Plage As Excel.Range
    ' Bills that needs to be transfered
    DoCmd.OpenQuery "Liste_factures_numero"

    ' Select answers
    SendKeys "^a", True
    ' Copy
    SendKeys "^c", True


    ' Opening Excel
    Set appXL = CreateObject("Excel.Application")
    appXL.Visible = True
    'Only XL 97 supports UserControl Property
    On Error Resume Next
    appXL.UserControl = True

    Set Classeur = appXL.Workbooks.Open("C:\Users\me\Desktop\copiedetravailvlvaccdb\reglements.xlsx")

    Set Cellule = Classeur.Worksheets(1).Cells(Classeur.Worksheets(1).Range("a1").CurrentRegion.Rows.Count + 1, 1)
    Cellule.Select

    ' Paste
    SendKeys "^v", True
    ' Cellule.PasteSpecial xlPasteValues
    ' Deleting titles
    Cellule.EntireRow.Delete

    'Fixing date format
    Set Plage = Selection
    For Each Cellule In Plage
        If Cellule.Column = 2 Then
            If Cellule.Value <> "" Then
                Cellule.Value = CDate(Cellule.Value)
            End If
        End If
    Next

    ' Mise au format normal
    Range("A3:D3").Copy
    Plage.PasteSpecial Paste:=xlFormats
    Excel.Application.CutCopyMode = False

    ' Closing request
    DoCmd.Close acQuery, "Liste_factures_numero", acSaveNo

Exit_CmdTransfert_Click:
    Exit Sub

Err_CmdTransfert_Click:
    MsgBox Err.Description
    Resume Exit_CmdTransfert_Click

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

答案 1 :(得分:4)

简短回答:View demo在发布时起作用

更长的答案:不应该,但有时候,例如当一个元素的兄弟没有变换时,某些浏览器don't handle the situation well,导致z-index被忽略了。

但一般情况下,这是因为应用了transform本身,而不是translateZ。在这种情况下的解决方案是它提供所有相关元素transform: translate3d(0px, 0px, 0px)或类似的东西,使浏览器更仔细地渲染元素