Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
309 views
in Technique[技术] by (71.8m points)

html - How to target certain text to make bold using css

At the moment the CSS selector .tag targets all text in the below and makes it bold. How would I just target the "Badge Name" text below

text to make bold?

wrapper.append('<div class="tag" >'+ 'Badge Name: '+ item.badgename + '</div>'+ '<br>');

Perhaps I need to use a pseudo selector?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Assuming the "Badge Name: " phrase is constant, one approach is using CSS :before pseudo element to generate the content as follows:

EXAMPLE HERE

.tag:before {
    content: "Badge Name: ";
    font-weight: bold;
}

Hence you could remove that phrase from your script:

wrapper.append('<div class="tag" >'+ item.badgename + '</div>'+ '<br>');

Another option is wrapping that phrase by an inline wrapper (a <span> element) and use .tag span selector to apply the proper declarations:

wrapper.append('<div class="tag" >'+ '<span>Badge Name:</span> '+ item.badgename + '</div>'+ '<br>');

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...