partial styled text in dynamic text

cpliu
cpliu Community Member Posts: 237
How can I change certain words to boldface in one dynamic text text block?

Comments

  • wendymiller
    wendymiller Community Member Posts: 244
    Hi cpliu,

    I've found it is possible to do this, but it's a bit fiddly because you have to use the same markup style as the dyntitle.xml, and you need to add your own CSS class to apply the style. It also only works once the title is hosted on a web server. So you cannot preview it locally.

    If you are familiar with adding CSS to your titles, add a class that has the style you want, such as:

    <style>
    .boldText{
    font-weight: bold;
    }
    </style>

    Then you need to edit the text you want to apply the style to in the dyntitle.xml something like this:

    &lt;span class=&quot;boldText&quot;  &gt;This is my bold text&lt;/span &gt;

    Hope this helps.
  • cpliu
    cpliu Community Member Posts: 237
    Thank you for the answer. dynamic text may not be the right term for what I would like to do.

    I actually just wanted to place text on screen using change content on a text field. For this case, I would like to show text. The passing score is 80% or better. while 80 is from a variable and I'd like to boldface 80%. For now, I put the 80 in its own field while align it with the rest of text. This can be a problem if I need to change text and which may alter the position of the rest of the text. It would be easier if I have the whole sentence in one field while still be able to boldface 80% in the text.

    I'm not sure how to apply what you described to my situation. How do I include CSS? If it's HTML Extension, what type should I use. Can I apply that to an text field than using dyntitle.xml?

    Thanks

     
  • wendymiller
    wendymiller Community Member Posts: 244
    Ah, I see. I thought you meant you had the title set to use dynamic text fields which is something completely different. That is where the dyntitle.xml comes into play. But that is irrelevant to what you're trying to do.

    Unfortunately, there is not currently an easy, built-in, way to modify the formatting of text when using the Change Contents action. Although I believe this feature has been requested many times, so hopefully it will be added to a future version of Lectora.

    In the meantime, some people have devised ways of using CSS and Javascript to do this. See Darrel Somoza's @klaatu reply to this thread. He's attached an example to his reply.

    http://community.trivantis.com/forums/topic/formatting-text-in-a-text-box/

    Also, this sample posted by Math Notermans @mnotermans5114 may help as well.

    http://community.trivantis.com/shared-content/manipulating-strings-with-javascript/

    If you download and inspect these examples, they will show you how to add the External HTML Objects for CSS and Javascript.

     
  • jvalley4735
    jvalley4735 Community Member Posts: 1,357
    Please make sure you utilize the up vote functionality for product suggestions :)  We want your voice heard when it comes to future enhancements.

    http://community.trivantis.com/forums/topic/change-contents-text-box/
Sign In or Register to comment.

So You Wanna Be An eLearning ROCKSTAR?

We're all fans of eLearning here! Want to become an eLearning ROCKSTAR? Just click on one of the buttons below to start your rocking journey!