Read the statement by Michael Teeuw here.
[Solved] Data layout - icon and text in same cell with spacing
-
Hi,
I’m nearly finished with my MMM-Hive module, but just have one issue that I cannot get my head around.
With the current code, the layout looks like this:

Notice the snowflake icon is right next to the Frost Protect Enabled text.
I would like it to look like this (proper icon spacing next to the text and also in line with the icon above) :

This is the relevant code:
var targetTemperatureRow = document.createElement("tr"); if (this.config.showNext == true) { var targetTemperatureCell = document.createElement("td"); targetTemperatureCell.colSpan = 5; if (this.insideTarget >= 1) { targetTemperatureCell.innerHTML = "Frost Protect Enabled"; targetTemperatureCell.className = "light dimmed xsmall"; var frostCell = document.createElement("span"); frostCell.setAttribute("aria-hidden","true"); frostCell.className = "fa fa-snowflake-o"; frostCell.style.cssText="color:white;"; targetTemperatureCell.appendChild(frostCell); targetTemperatureRow.appendChild(targetTemperatureCell); } else { targetTemperatureCell.innerHTML = this.config.targetTempText + " " + this.insideTarget + this.config.temperatureSuffix; targetTemperatureCell.className = "light xsmall"; targetTemperatureRow.appendChild(targetTemperatureCell); }} table.appendChild(temperatureRow); table.appendChild(targetTemperatureRow);I was looking at using flexbox, but I’m loathe to spend another x amount of hours and just want to get this module finished now :)
If anyone has any ideas on the above, it will be greatly appreciated, and might prevent me from pulling any more hair out!
Thanks
-
I’ve been ‘googling’ since posting and have found the solution (may not be the best solution, but it is now working).
I’ll put it here as it may help someone, or someone else may have a better suggestion:
targetTemperatureCell.insertBefore(frostCell, targetTemperatureCell.firstChild);
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login