【问题标题】:css transform:rotate(xdeg) puts element always in foregroundcss transform:rotate(xdeg) 将元素始终放在前台
【发布时间】:2018-04-23 11:27:09
【问题描述】:

i have 2 Pictures, 我想旋转光标。

工作正常,但我的导航栏是固定的,图像(光标)总是在导航栏的top 上。

这是我的代码:

[0].head1 { // navbar
[1]  position:fixed;
[2]  min-width:100%;
[3]  margin-top: 3rem;
[4]  z-index:14;
[5]}
[6]#cursor{ // cursor
[7]  margin-top: -48px;
[8]  transform: rotate(180deg);
[9]}

我尝试过使用光标的 z-index,并尝试了所有可能的位置。如果我在我的代码中删除第 8 行,它工作得很好,除了 roation..

我的 html 是:(我知道所有这些 head1、head2 等都不是必需的,我稍后会更改。

<div id="head1" class="head1">
    <div id="head2" class="head2">
      <div id="head3" class="head3">
        <p id="blabla" class="blabla">......</p>
        <div id="head4" class="head4">
          <p id="text" class="text"></p>
        </div>
        <div class="blend">
        </div>
      </div>
    </div>
  </div>
  <div class="content">

    <div style="min-height:13rem;"></div><!-- Spacer-->

    <table style="width:100%">
      <tr>
        <td class="detailEntrie"><strong>2012</strong></br>2013</td>
        <td class="detailEntrie"><strong>116i</strong></br>320d</td>
        <td class="detailEntrie"><strong>Juli</strong></br>September</td>
        <td class="detailEntrie">
          <p>Drivable?</p>
          <img src="assets/images/drivablemeter.png" alt="Driveable?" style="width:100px;">
          <img id="cursor" src="assets/images/drivablecursor.png" alt="Driveable?" style="width:100px;">

        </td> 
      </tr>
    </table>

【问题讨论】:

  • 请提供您的html
  • 已编辑,但没有什么特别之处,所以我一开始没有包含它
  • 你能把图片也给我们吗?问题可能是,光标不是绝对的。你想把光标放在“可驱动”上面不是吗?
  • glascake.com/testpublish你可以在这里找到完整的页面,这将在几周内被删除

标签: javascript html css rotation transform


【解决方案1】:

您没有为固定的 .head1 指定任何 z-index 确保至少放置

.head1 {z-index: 1} 

到固定导航。请注意,z-index: 14 存在于您的原始代码中,但在您的真实页面示例中 - 它不存在

【讨论】:

  • 谢谢,但是为什么我把样式写在HTML里面,但是样式已经在我的css中了,它不起作用
  • 啊,我看到有语法错误。事实上,你不应该在 CSS 中使用 '//' cmets,而应该使用 '/* cmets */'。因此,请在您的 CSS 中替换或删除此代码 prntscr.com/j8z1zg
猜你喜欢
  • 2019-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-27
  • 2015-08-16
  • 1970-01-01
相关资源
最近更新 更多