1

I need to transform my uppercase text in capitalize text in the html page.

<ng-container *ngFor="let item of parameterStruct">
  <span class="sideBar-text" style="font-size: 12px"> 
    {{item.description}}
  </span>
</ng-container>

From item.description I get an uppercase text. Is there a way to use a css property in order to have a capitalize text?

GigiProve
  • 337
  • 1
  • 5
  • 15

3 Answers3

4

The thing is capitalize won't lowercase other characters from an uppercase text. What you can do is

.sideBar-text{
    text-transform : lowercase;
}

.sideBar-text:first-letter{
    text-transform : uppercase;
}

https://www.sassmeister.com/gist/d2c9fe2e136efefbdb59a9ae4ee4e689

Hope it helps ;)

  • This works only if its one word per html-element – N4ppeL Aug 27 '19 at 08:58
  • I don't get it : check this link, I think it's a two words HTML ;) https://www.sassmeister.com/gist/d2c9fe2e136efefbdb59a9ae4ee4e689 – jean-charles Bonnard Aug 27 '19 at 09:23
  • Yes. "world" is lowercase. Capitalize would mean to output "Hello World". Not sure tough if this is really what is intended by GigiProve, but if not the question should be edited accordingly – N4ppeL Aug 27 '19 at 09:35
  • Oh, right, depends on what he wants ! In my head it was clear he only wanted the first letter =D What about angular lowercase pipe combined with CSS capitalize then ? – jean-charles Bonnard Aug 27 '19 at 09:44
-1

Have you tried capitalize?

.capitalize {
  text-transform: capitalize;
}

<span class="sideBar-text capitalize" style="font-size: 12px"> 
  {{item.description}}
</span>
Riku
  • 652
  • 1
  • 9
  • 24
-3

You can use css text-transform: capitalize; to make text to Upper case.

More description can be found here : https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform

Darpan Rangari
  • 1,494
  • 11
  • 22