2016-10-17 8 views
4

私は、テーブル内のローダーを入れしようとしていますが、それは動作しません。問題は、私がtdの中にdivを置いているときです。表形式は動作しません。私はdiv要素がテーブルの外で要素を検査 ローダー​​

.loader { 
 
    background: #000; 
 
    background: radial-gradient(#222, #000); 
 
    bottom: 0; 
 
    left: 0; 
 
    overflow: hidden; 
 
    position: fixed; 
 
    right: 0; 
 
    top: 0; 
 
    z-index: 99999; 
 
} 
 
.loader-inner { 
 
    height: 60px; 
 
    left: 0; 
 
    position: absolute; 
 
    right: 0; 
 
    width: 100px; 
 
} 
 
.loader-line-wrap { 
 
    animation: spin 2000ms cubic-bezier(.175, .885, .32, 1.275) infinite; 
 
    box-sizing: border-box; 
 
    height: 50px; 
 
    left: 0; 
 
    overflow: hidden; 
 
    position: absolute; 
 
    top: 0; 
 
    transform-origin: 50% 100%; 
 
    width: 100px; 
 
} 
 
.loader-line { 
 
    border: 4px solid transparent; 
 
    border-radius: 100%; 
 
    box-sizing: border-box; 
 
    height: 100px; 
 
    left: 0; 
 
    margin: 0 auto; 
 
    position: absolute; 
 
    right: 0; 
 
    top: 0; 
 
    width: 100px; 
 
} 
 
.loader-line-wrap:nth-child(1) { 
 
    animation-delay: -50ms; 
 
} 
 
.loader-line-wrap:nth-child(2) { 
 
    animation-delay: -100ms; 
 
} 
 
.loader-line-wrap:nth-child(3) { 
 
    animation-delay: -150ms; 
 
} 
 
.loader-line-wrap:nth-child(4) { 
 
    animation-delay: -200ms; 
 
} 
 
.loader-line-wrap:nth-child(5) { 
 
    animation-delay: -250ms; 
 
} 
 
.loader-line-wrap:nth-child(1) .loader-line { 
 
    border-color: hsl(0, 80%, 60%); 
 
    height: 90px; 
 
    width: 90px; 
 
    top: 7px; 
 
} 
 
.loader-line-wrap:nth-child(2) .loader-line { 
 
    border-color: hsl(60, 80%, 60%); 
 
    height: 76px; 
 
    width: 76px; 
 
    top: 14px; 
 
} 
 
.loader-line-wrap:nth-child(3) .loader-line { 
 
    border-color: hsl(120, 80%, 60%); 
 
    height: 62px; 
 
    width: 62px; 
 
    top: 21px; 
 
} 
 
.loader-line-wrap:nth-child(4) .loader-line { 
 
    border-color: hsl(180, 80%, 60%); 
 
    height: 48px; 
 
    width: 48px; 
 
    top: 28px; 
 
} 
 
.loader-line-wrap:nth-child(5) .loader-line { 
 
    border-color: hsl(240, 80%, 60%); 
 
    height: 34px; 
 
    width: 34px; 
 
    top: 35px; 
 
} 
 
@keyframes spin { 
 
    0%, 15% { 
 
    transform: rotate(0); 
 
    } 
 
    100% { 
 
    transform: rotate(360deg); 
 
    } 
 
}
<table> 
 
    <tr> 
 
    <td>1</td> 
 
    </tr> 
 
    <tr> 
 
    <td> 
 
     <div id="preloader" class="loader"> 
 
     <div class="loader-inner"> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
     </div> 
 
     </div> 
 
    </td> 
 
    </tr> 
 
</table>

+0

それは私の側のチェックhttps://jsfiddle.net/dbwog4zt/で働いています。あなたの問題を示すjsfiddleを投稿してください。 – geeksal

+0

@geeksal私はOPのロードは、彼らが固定された位置を使用しているため、発生しません ''​​内に含まれることを望んでいると信じています。 – hungerstar

+0

私も同じ出力を得ています。正確に私が望むのは、ローダーがテーブルの中にいる必要があるということです。私はちょうど背景をコメントし、表の境界を追加しました。これを見てください。https://jsfiddle.net/dbwog4zt/ –

答えて

6

あなたは<td>内のローディングのグラフィックが含まれている必要があるなら、あなたは、固定位置を使用しないでください。

は、ここに1つのソリューションです。固定された配置と関連するプロパティを削除します。 .loaderの高さと幅に沿った相対的な位置合わせを設定します。

.loader { 
 
    position: relative; 
 
    background: #000; 
 
    background: radial-gradient(#222, #000); 
 
    overflow: hidden; 
 
    z-index: 99999; 
 
    width: 100px; 
 
    height: 100px; 
 
} 
 
.loader-inner {} 
 
.loader-line-wrap { 
 
    animation: spin 2000ms cubic-bezier(.175, .885, .32, 1.275) infinite; 
 
    box-sizing: border-box; 
 
    height: 50px; 
 
    left: 0; 
 
    overflow: hidden; 
 
    position: absolute; 
 
    top: 0; 
 
    transform-origin: 50% 100%; 
 
    width: 100px; 
 
} 
 
.loader-line { 
 
    border: 4px solid transparent; 
 
    border-radius: 100%; 
 
    box-sizing: border-box; 
 
    height: 100px; 
 
    left: 0; 
 
    margin: 0 auto; 
 
    position: absolute; 
 
    right: 0; 
 
    top: 0; 
 
    width: 100px; 
 
} 
 
.loader-line-wrap:nth-child(1) { 
 
    animation-delay: -50ms; 
 
} 
 
.loader-line-wrap:nth-child(2) { 
 
    animation-delay: -100ms; 
 
} 
 
.loader-line-wrap:nth-child(3) { 
 
    animation-delay: -150ms; 
 
} 
 
.loader-line-wrap:nth-child(4) { 
 
    animation-delay: -200ms; 
 
} 
 
.loader-line-wrap:nth-child(5) { 
 
    animation-delay: -250ms; 
 
} 
 
.loader-line-wrap:nth-child(1) .loader-line { 
 
    border-color: hsl(0, 80%, 60%); 
 
    height: 90px; 
 
    width: 90px; 
 
    top: 7px; 
 
} 
 
.loader-line-wrap:nth-child(2) .loader-line { 
 
    border-color: hsl(60, 80%, 60%); 
 
    height: 76px; 
 
    width: 76px; 
 
    top: 14px; 
 
} 
 
.loader-line-wrap:nth-child(3) .loader-line { 
 
    border-color: hsl(120, 80%, 60%); 
 
    height: 62px; 
 
    width: 62px; 
 
    top: 21px; 
 
} 
 
.loader-line-wrap:nth-child(4) .loader-line { 
 
    border-color: hsl(180, 80%, 60%); 
 
    height: 48px; 
 
    width: 48px; 
 
    top: 28px; 
 
} 
 
.loader-line-wrap:nth-child(5) .loader-line { 
 
    border-color: hsl(240, 80%, 60%); 
 
    height: 34px; 
 
    width: 34px; 
 
    top: 35px; 
 
} 
 
@keyframes spin { 
 
    0%, 15% { 
 
    transform: rotate(0); 
 
    } 
 
    100% { 
 
    transform: rotate(360deg); 
 
    } 
 
} 
 
table td { 
 
    border: 1px solid #CCC; 
 
}
<table> 
 
    <tr> 
 
    <td>1</td> 
 
    </tr> 
 
    <tr> 
 
    <td> 
 
     <div id="preloader" class="loader"> 
 
     <div class="loader-inner"> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
     </div> 
 
     </div> 
 
    </td> 
 
    </tr> 
 
</table>

+0

迅速な対応のためにhungerstarとgeeksalに感謝します。今働いている。 –

1

ローダーの親tdにIDやクラスを追加し、relativeにその位置を設定します。ローダーの位置をabsoluteにします。

#loaderContainer { 
 
    position: relative; 
 
    height: 100px; 
 
    width: 100px; 
 
} 
 
.loader { 
 
    background: #000; 
 
    background: radial-gradient(#222, #000); 
 
    bottom: 0; 
 
    left: 0; 
 
    overflow: hidden; 
 
    position: absolute; 
 
    right: 0; 
 
    top: 0; 
 
    z-index: 99999; 
 
} 
 
.loader-inner { 
 
    height: 60px; 
 
    left: 0; 
 
    position: absolute; 
 
    right: 0; 
 
    width: 100px; 
 
} 
 
.loader-line-wrap { 
 
    animation: spin 2000ms cubic-bezier(.175, .885, .32, 1.275) infinite; 
 
    box-sizing: border-box; 
 
    height: 50px; 
 
    left: 0; 
 
    overflow: hidden; 
 
    position: absolute; 
 
    top: 0; 
 
    transform-origin: 50% 100%; 
 
    width: 100px; 
 
} 
 
.loader-line { 
 
    border: 4px solid transparent; 
 
    border-radius: 100%; 
 
    box-sizing: border-box; 
 
    height: 100px; 
 
    left: 0; 
 
    margin: 0 auto; 
 
    position: absolute; 
 
    right: 0; 
 
    top: 0; 
 
    width: 100px; 
 
} 
 
.loader-line-wrap:nth-child(1) { 
 
    animation-delay: -50ms; 
 
} 
 
.loader-line-wrap:nth-child(2) { 
 
    animation-delay: -100ms; 
 
} 
 
.loader-line-wrap:nth-child(3) { 
 
    animation-delay: -150ms; 
 
} 
 
.loader-line-wrap:nth-child(4) { 
 
    animation-delay: -200ms; 
 
} 
 
.loader-line-wrap:nth-child(5) { 
 
    animation-delay: -250ms; 
 
} 
 
.loader-line-wrap:nth-child(1) .loader-line { 
 
    border-color: hsl(0, 80%, 60%); 
 
    height: 90px; 
 
    width: 90px; 
 
    top: 7px; 
 
} 
 
.loader-line-wrap:nth-child(2) .loader-line { 
 
    border-color: hsl(60, 80%, 60%); 
 
    height: 76px; 
 
    width: 76px; 
 
    top: 14px; 
 
} 
 
.loader-line-wrap:nth-child(3) .loader-line { 
 
    border-color: hsl(120, 80%, 60%); 
 
    height: 62px; 
 
    width: 62px; 
 
    top: 21px; 
 
} 
 
.loader-line-wrap:nth-child(4) .loader-line { 
 
    border-color: hsl(180, 80%, 60%); 
 
    height: 48px; 
 
    width: 48px; 
 
    top: 28px; 
 
} 
 
.loader-line-wrap:nth-child(5) .loader-line { 
 
    border-color: hsl(240, 80%, 60%); 
 
    height: 34px; 
 
    width: 34px; 
 
    top: 35px; 
 
} 
 
@keyframes spin { 
 
    0%, 15% { 
 
    transform: rotate(0); 
 
    } 
 
    100% { 
 
    transform: rotate(360deg); 
 
    } 
 
}
<table> 
 
    <tr> 
 
    <td>1</td> 
 
    </tr> 
 
    <tr> 
 
    <td id="loaderContainer"> 
 
     <div id="preloader" class="loader"> 
 
     <div class="loader-inner"> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
      <div class="loader-line-wrap"> 
 
      <div class="loader-line"></div> 
 
      </div> 
 
     </div> 
 
     </div> 
 
    </td> 
 
    </tr> 
 
</table>

+0

@ hungester - あなたはなぜ私の答えからjsfiddleリンクが削除されているのか教えてください。具体的な理由は何ですか? –

+10

は、同じ理由でStackOverflowのではなく、ウェブサイトにまたはコードオフサイトへのリンクを、最小の完全、かつ検証例を投稿する人を求めます。将来の来館者は、含まれているすべてのものを保つことによって、将来利用できない外部リソースについて心配する必要はありません。あなたのコードはStackOverflowだけでスニペットで実行されるようになりました。あなたの例は非常に簡単で、SOコードスニペットの機能の中にあります。 JSFiddle/CodePenはSOコードスニペットよりも機能が豊富で、代わりに使用されることもあります。 – hungerstar