css - 以 Angular 自定义 css 加载器

标签 css html angular

我有这个loader工作正常。 enter image description here

CSS:

.loader {
      border: 16px solid #f3f3f3;
      border-radius: 50%;
      border-top: 16px solid #3498db;
      width: 120px;
      height: 120px;
      -webkit-animation: spin 2s linear infinite; /* Safari */
      animation: spin 2s linear infinite;
    }
    
    /* Safari */
    @-webkit-keyframes spin {
      0% { -webkit-transform: rotate(0deg); }
      100% { -webkit-transform: rotate(360deg); }
    }
    
    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
<div *ngIf="somevalue" class="loader"></div>

现在我需要把一些文字放在中间

enter image description here

但我的尝试不起作用。我怎样才能让我的装载机像第二张图片一样?我不想安装更多外部组件,md-progress-loader、md-circle...等。TRY IT

最佳答案

一个非常简单的解决方案是将文本放入另一个 div 并相应地定位它 - 就像

<div class="container">
 <div class="loader"></div>
 <div class="description">Text</div>
</div>

.description
{
   position: absolute;
   top:0;
   left:0;
   line-height:150px;
   width:152px;
   text-align:center;
}

.container
{
   position:relative;
}

关于css - 以 Angular 自定义 css 加载器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49721197/

相关文章:

javascript - 模拟背景: cover; with fixed values?

html - 保持在最前面的 CSS 工具提示

java - 如何使用 Html 单元和 Xpath 获取段落元素

angular cli 必须使用 import 来加载 ES 模块

javascript - 为什么 ngc 部分忽略compileroptions.outDir?是否存在解决方法?

css - 从 CSS 调整图像大小

html - 应用于 :before element of css did not get applied to the entire div 的背景

html - 什么时候为 css 使用 div#idname 或 #idname

html - 将任何网站布局或模板转换为 Drupal 8 主题

css - Angular 2 : Styling router-outlet to have width < 100%