[英]How to make background transparent while bootstrap loader
I want to make a bootstrap loading image while API returns a result. 我想在API返回结果的同时创建引导加载图片。 How can I make the background transparent?
如何使背景透明?
Here is the HTML markup and the CSS: 这是HTML标记和CSS:
<div class="loader" ng-hide="data.length > 0"></div> <style> .loader { border: 16px solid #D4D4D4; border-radius: 50%; border-top: 16px solid #3498db; width: 120px; height: 120px; position: fixed; top:100px; bottom: 0; left: 0; right: 0; margin: auto; z-index: 99999999; -webkit-animation: spin 2s linear infinite; animation: spin 2s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } </style>
Add background-color: transparent to .loader 添加背景颜色:对.loader透明
<div class="loader" ng-hide="data.length > 0"></div> <style> .loader { border: 16px solid #D4D4D4; border-radius: 50%; border-top: 16px solid #3498db; width: 120px; background-color: transparent; height: 120px; position: fixed; top:100px; bottom: 0; left: 0; right: 0; margin: auto; z-index: 99999999; -webkit-animation: spin 2s linear infinite; animation: spin 2s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } </style>
You can always add a div of smaller size over the page with the loader and make it a light gray and put the opacity lower like: 您始终可以使用加载程序在页面上添加较小尺寸的div,并将其设置为浅灰色,然后将不透明度降低,例如:
#div1{ width:500px; height:500px; background-image: url("https://images3.alphacoders.com/823/82317.jpg"); } #div2{ width:200px; height:200px; margin: 0 auto; background-color:gray; opacity:.7; position:absolute; top:150px; left:150px; }
<div id="div1"> <div id="div2"> </div> </div>
You can then place the loader inside that smaller div and have that div appear when the API is fetching the data. 然后,您可以将加载程序放置在较小的div内,并在API提取数据时让该div出现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.