MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    How can I inject some CSS styles in a block of text in Javascript so I can differentiate two different blocks of text

    Scheduled Pinned Locked Moved Development
    2 Posts 2 Posters 949 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mediathreatM Offline
      mediathreat
      last edited by mediathreat

      Hi I’m kludging some code together, how Can i inject some CSS into this terrible piece of javascript I hacked together. I want to style the elements so that the title is different from the text. Here is what my screen looks like now - its the center piece about Super Troopers:

      alt text
      Id love to bold out "super troopers paul soter is a nimbly-bimly adman as a title to seperate it from the rest of it which is the text/description part.

      Here’s my code block that generates this:

      var ratio = Math.min(200 / Number(fix_width) , 200 / Number(fix_height));
      		var width = fix_width*ratio;
      		var height = fix_height*ratio;
      		var messageElement = document.createElement('div');
      		messageElement.className = 'light medium';
      		messageElement.innerHTML = "<table><tr><td><img src=" + image_bed + " /></td><td>" +  this.slackMessages[0].title + "</td></tr><tr><td>" + this.slackMessages[0].text + "</td></tr></table>";
      		}
      		return messageElement;
      
      
      strawberry 3.141S 1 Reply Last reply Reply Quote 0
      • strawberry 3.141S Offline
        strawberry 3.141 Project Sponsor Module Developer @mediathreat
        last edited by

        @mediathreat you have different possibilities, e.g.

        add a class

        in your td tag add a class attribute class='MyFancyTitle', the forum don't want to render it. Then in your css you can style this class
        

        or add inline styling

        in your td tag add a style attribute style='font-weight: bold'
        

        Please create a github issue if you need help, so I can keep track

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Enjoying MagicMirror? Please consider a donation!
        MagicMirror created by Michael Teeuw.
        Forum managed by Sam, technical setup by Karsten.
        This forum is using NodeBB as its core | Contributors
        Contact | Privacy Policy