z-index不能按预期工作多个项目

时间:2017-11-23 03:07:53

标签: html css css3 z-index

如果div出现在另一个div之上,即使它出现在HTML之前,我怎样才能得到div。

如果你看下面的例子,我们需要在最前面出现logo div。



div
{
    height: 200px;
    width: 200px;
    background: #0f0;
}

.parent
{
    position: relative;
    z-index: 1;
}

.child
{
    position: fixed;
    z-index: 2;
    top: 70px; 
    left: 30px;
    background: #f00;
    height: 60px;
}


.child-2
{
    position: inherit;
    z-index: 6;
    top: 10px; 
    left: 30px;
    background: blue;
     height: 60px;
}

<div class="parent">
    header background repeated image
    <div class="child-2">
      logo
    </div>
</div>

<div class="child">
  hero image
</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

您无需将Schema::create('companies', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id'); $table->string('companyName'); $table->string('logo')->nullable(); $table->string('contactPerson'); $table->string('employeeSize'); ​ ... Schema::create('jobs', function (Blueprint $table) { $table->increments('id'); $table->integer('company_id'); $table->string('jobTitle'); $table->longText('jobDescription'); $table->longText('jobRequirement'); $table->date('deadline'); ​ ... 提供给其他区块 只需将它标记为徽标即可。

z-index
div {
  height: 200px;
  width: 200px;
  background: #0f0;
}

.parent {
  position: relative;
}

.child {
  position: fixed;
  top: 70px;
  left: 30px;
  background: #f00;
  height: 60px;
}

.child-2 {
  position: inherit;
  z-index: 16;
  top: 10px;
  left: 30px;
  background: blue;
  height: 60px;
}