Is it possible to have multiple span classes on the same line without using div s?
P粉035600555
P粉035600555 2024-04-03 11:17:18
0
1
451

I wanted each text to have a different color, so I used multiple span classes to set the colors in css. I also wanted the text to have line breaks, so I used a div. This fiddle shows the results I want, but the div tags used for line breaks create large gaps. Is there another way to do line wrapping in multiple span classes?

Fiddle: https://jsfiddle.net/nh7vswco/

<pre id="info">
       
                <div class = "fact-card">               
                <span class="animal">  animal</span>
                <span class="colon"> : </span>
                <span class="animal-name">tiger</span>
                <span class="comma">,</span> 
                </div> 
                
                <div class = "fact-card">
                <span class="animal">  species</span>
                <span class="colon"> : </span>
                <span class="animal-name">Mammal</span>
                <span class="comma">,</span>
                </div>
                
                <div class = "fact-card">
                <span class="animal">  type</span>
                <span class="colon"> : </span>
                <span class="animal-name">carnivore</span>
                <span class="comma">,</span>
                </div>
Result:
Each word and colon should have a different color.
animal : tiger,
species : mammal,
type : carnivore,

The result of this fiddle is: https://jsfiddle.net/nh7vswco/, but I want to remove the gaps in the div tags.

P粉035600555
P粉035600555

reply all(1)
P粉574268989

1- There are many ways to do line breaks like this:
or line-break CSS properties.

2- Remove gaps in div tags. We can use line-height: 0%;

  
       
    
animal : tiger ,
species : Mammal ,
type : carnivore ,
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template