0

I have this loader working fine. 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>

Now I need put some text in center

enter image description here

but my try not working. How Can I let my loader like in second image? I dont want install more external components, md-progress-loader, md-circle...etc.. TRY IT

2 Answers 2

1

A very simple solution is to just place the text into another div and position it accordingly - something like

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

and

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

.container
{
   position:relative;
}
Sign up to request clarification or add additional context in comments.

1 Comment

@DiegoVenâncio Can you clarify in what way it isn't working? Here is a plunkr with the full setup plnkr.co/edit/K2k2Q7eWg8zp2peQCSZY?p=preview
1

This counters the rotation and provides a roughly sane box in which other elements can be placed.

.loader {
  border: 16px solid #f3f3f3;
  border-radius: 50%;
  border-top: 16px solid #3498db;
  width: 120px;
  height: 120px;
  animation: spin 2s linear infinite;
}


@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loader div {
  display: block;
  animation: spin 2s linear infinite reverse;
  position: relative;
  height: 100%;
}

.loader div span {
  display: inline-block;
  text-align: center;
}
<div *ngIf="somevalue" class="loader"><div><span>testing lots of text in this text box</span></div></div>

2 Comments

Your code appear all right but my 'text' are twirl together loader.
@DiegoVenâncio Could you clarify? I don't see what you mean by "twirl together loader".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.