<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[centering image with a colspan = 2]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I’m trying to modify someones weather app to make it span across the bottom of the right side of the page.  The initial module looks like it was just copy pasted from the default weather forecast module.  It is the MMM-weatherforecast by jharttech.  I’ve reach out to him with no response, so I’m asking here.  What I want is basically 3 rows by 2 cells with the first row being the day spanning 2 cells, second being a weather icon spanning 2 cells, and the third row being the hi and low temperature.  I’ve got almost everything figured out except getting the icon centered between the two cells.  If I take out the code he added and add test text the text is centered between two cells.  I cannot figure this out.  I’ve tried colspan, changing them between tr, td, and span.  Nothing I am doing seems to be working right.</p>
<pre><code>  var table = document.createElement("table");
		table.className = this.config.tableClass;

		switch (this.config.layout){
		case "horizontal":
			for (var f in this.forecast) {
				var forecast = this.forecast[f];

				var row = document.createElement("td");
				if (this.config.colored) {
					row.className = "colored";
				}
				table.appendChild(row);

				var dayCell = document.createElement("td");
				dayCell.colSpan = 2;
				dayCell.className = "day";
				dayCell.innerHTML = forecast.day;
				row.appendChild(dayCell);
				
				var iconCell = document.createElement("tr");
				iconCell.colSpan = 2;
				iconCell.style.textAlign = "center";
				iconCell.className = "bright-weather-icon";
				row.appendChild(iconCell);
				

				var icon = document.createElement("span");
				icon.colSpan = 2;
				icon.style.textAlign = "center";
				icon.className = "wi-weathericon " + forecast.icon;
				iconCell.appendChild(icon);
								
				var degreeLabel = "&amp;deg;";
				if(this.config.scale) {
					switch(this.config.units) {
					case "metric":
						degreeLabel += " C";
						break;
					case "imperial":
						degreeLabel += " F";
						break;
					case "default":
						degreeLabel = "K";
						break;
					}
				}

				if (this.config.decimalSymbol === "" || this.config.decimalSymbol === " ") {
					this.config.decimalSymbol = ".";
				}

				var maxTempCell = document.createElement("td");
				maxTempCell.innerHTML = "Hi:" + forecast.maxTemp.replace(".", this.config.decimalSymbol) + degreeLabel;
				maxTempCell.className = "max-temp";
				row.appendChild(maxTempCell);

				var minTempCell = document.createElement("td");
				minTempCell.innerHTML = "Lo:" + forecast.minTemp.replace(".", this.config.decimalSymbol) + degreeLabel;
				minTempCell.className = "min-temp";
				row.appendChild(minTempCell);

				if (this.config.showRainAmount) {
					var rainCell = document.createElement("td");
					if (isNaN(forecast.rain)) {
						rainCell.innerHTML = "";
					} else {
						if(config.units !== "imperial") {
							rainCell.innerHTML = parseFloat(forecast.rain).toFixed(1) + " mm";
						} else {
							rainCell.innerHTML = (parseFloat(forecast.rain) / 25.4).toFixed(2) + " in";
						}
					}
					rainCell.className = "align-right bright rain";
					row.appendChild(rainCell);
				}
</code></pre>
]]></description><link>https://forum.magicmirror.builders/topic/10499/centering-image-with-a-colspan-2</link><generator>RSS for Node</generator><lastBuildDate>Mon, 20 Jul 2026 16:28:22 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/10499.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 22 May 2019 22:53:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to centering image with a colspan = 2 on Fri, 24 May 2019 19:54:56 GMT]]></title><description><![CDATA[<p dir="auto">well I got it to work.  I ended up  having to set the left border to 50% in the css.</p>
]]></description><link>https://forum.magicmirror.builders/post/57391</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/57391</guid><dc:creator><![CDATA[wegz15]]></dc:creator><pubDate>Fri, 24 May 2019 19:54:56 GMT</pubDate></item><item><title><![CDATA[Reply to centering image with a colspan = 2 on Fri, 24 May 2019 19:28:19 GMT]]></title><description><![CDATA[<p dir="auto">Here is what I added…</p>
<pre><code>var iconCell = document.createElement("tr");
				iconCell.colSpan = 2;
				iconCell.style.textAlign = "center";
				iconCell.className = "bright-weather-icon";
                                row.appendChild(iconCell);
				

				var icon = document.createElement("span");
				icon.colSpan = 2;
				icon.style.textAlign = "center";
				icon.className = "wi-weathericon" + forecast.icon;
				iconCell.appendChild(icon);
				
				var i=document.createElement("img");
				i.src = "wi-weathericon " + forecast.icon;
				iconCell.appendChild(i);
</code></pre>
<p dir="auto">that shows up with an empty square below the current left aligned image.  I tried deleting the var icon and got just a blank sqaure…here is the code plus element from chrome.</p>
<pre><code>                                var iconCell = document.createElement("tr");
				iconCell.colSpan = 2;
				iconCell.style.textAlign = "center";
				iconCell.className = "bright-weather-icon";
				row.appendChild(iconCell);
				
                                var i=document.createElement("img");
				i.src = "wi-weathericon " + forecast.icon;
				iconCell.appendChild(i);

</code></pre>
<p dir="auto">chrome inspector shows this:</p>
<pre><code>&lt; tr class="bright-weather-icon" style="text-align: center;"&gt;&lt; img src="wi-weathericon night-rain"&gt;&lt; /tr&gt;

</code></pre>
<p dir="auto">and then the css shows this:</p>
<pre><code>.night-rain{
	content: "";
	height:70px;
	width:105px;
	display: block; 
	background-image : url("/css/icon/45.png");
	background-size: 105px 70px;
	background-position: center;
	text-align: center;
}
</code></pre>
<p dir="auto">so I need that to be the class so it replaces it with the correct image…but still don’t know how to center that</p>
]]></description><link>https://forum.magicmirror.builders/post/57390</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/57390</guid><dc:creator><![CDATA[wegz15]]></dc:creator><pubDate>Fri, 24 May 2019 19:28:19 GMT</pubDate></item><item><title><![CDATA[Reply to centering image with a colspan = 2 on Fri, 24 May 2019 12:52:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/wegz15" aria-label="Profile: wegz15">@<bdi>wegz15</bdi></a>   you would use the image tag<br />
note the image tag below has a e+xtra space after the open as this forum uses that tag, and stuff disappears</p>
<pre><code>&lt; img src="url"&gt;&lt;/img&gt;
</code></pre>
<p dir="auto">so,</p>
<pre><code>var i= createElement("img")..
i.src=....
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/57379</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/57379</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Fri, 24 May 2019 12:52:34 GMT</pubDate></item><item><title><![CDATA[Reply to centering image with a colspan = 2 on Fri, 24 May 2019 12:32:59 GMT]]></title><description><![CDATA[<p dir="auto">Sorry, I’m pretty new at this.  I took a basic web design class with very basic css about 15 years ago.  I guess what I’m asking is how do I source an image?  I want to display the weather image based on the api response.  My assumption of why it is not working is because currently the image is being called by the class name.   When I inspect the cell in chrome inspector I see this:</p>
<p dir="auto">(span class=“wi-weathericon rains” style=“text-align: center;”) (/span)</p>
<p dir="auto">The code calls for (icon.className = "wi-weathericon " + forecast.icon;)</p>
<p dir="auto">When I change it to imgSrc = "wi-weathericon " + forecast.icon; I get an empty sqaure displayed.  I tried imgSrc = /modules/icon/"wi-weathericon " + forecast.icon; and that makes the module not show up.</p>
]]></description><link>https://forum.magicmirror.builders/post/57378</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/57378</guid><dc:creator><![CDATA[wegz15]]></dc:creator><pubDate>Fri, 24 May 2019 12:32:59 GMT</pubDate></item><item><title><![CDATA[Reply to centering image with a colspan = 2 on Fri, 24 May 2019 11:24:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/wegz15" aria-label="Profile: wegz15">@<bdi>wegz15</bdi></a> I don’t understand the question…</p>
<p dir="auto">YOU set the classname</p>
<p dir="auto">icon.className = "wi-weathericon " + forecast.icon;</p>
<p dir="auto">see <a href="https://stackoverflow.com/questions/8603914/center-image-in-table-td-in-css/8603927" target="_blank" rel="noopener noreferrer nofollow ugc">https://stackoverflow.com/questions/8603914/center-image-in-table-td-in-css/8603927</a></p>
]]></description><link>https://forum.magicmirror.builders/post/57375</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/57375</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Fri, 24 May 2019 11:24:26 GMT</pubDate></item><item><title><![CDATA[Reply to centering image with a colspan = 2 on Fri, 24 May 2019 03:37:58 GMT]]></title><description><![CDATA[<p dir="auto">So,  I got it to load. There was a capitalization mistake.  It still won’t center.  Looking at it in the inspector I noticed that the class name is the cell image I want to display.  How would I get the class to be standardized and the source html to change based on the weather? So there is basicall nothing in the cell for it to center.  The colspan attribute does not show up as well.</p>
<pre><code>&lt;tr class= "bright-weather-icon" style="text-align: center;"&gt;
   &lt;div&gt;
       &lt;tr class="wi-weathericon night-cloudy" style="text-align: center;"&gt; &lt;/tr&gt;
   &lt;/div&gt;
&lt;/tr&gt;
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/57369</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/57369</guid><dc:creator><![CDATA[wegz15]]></dc:creator><pubDate>Fri, 24 May 2019 03:37:58 GMT</pubDate></item><item><title><![CDATA[Reply to centering image with a colspan = 2 on Fri, 24 May 2019 03:10:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a>  that does not load anything.  I copied and pasted it as you wrote it.  It just says “Loading…”</p>
]]></description><link>https://forum.magicmirror.builders/post/57368</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/57368</guid><dc:creator><![CDATA[wegz15]]></dc:creator><pubDate>Fri, 24 May 2019 03:10:38 GMT</pubDate></item><item><title><![CDATA[Reply to centering image with a colspan = 2 on Thu, 23 May 2019 03:40:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/wegz15" aria-label="Profile: wegz15">@<bdi>wegz15</bdi></a>  use the same code u have to make a div object, and then append the image to that, and append the DIV  to the dom</p>
<pre><code>var iconCell = document.createElement("tr");
				iconCell.colSpan = 3;
				iconCell.style.textAlign = "center";
				iconCell.className = "bright-weather-icon";
				row.appendChild(iconCell);
var iconDiv = document.createElement("div");
var icon = document.createElement("span");
				icon.style.textAlign = "center";
				icon.className = "wi-weathericon " + forecast.icon;
				iconDiv.appendChild(icon);
                                iconcell.appendChild(iconDiv)
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/57329</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/57329</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 23 May 2019 03:40:53 GMT</pubDate></item><item><title><![CDATA[Reply to centering image with a colspan = 2 on Thu, 23 May 2019 01:06:49 GMT]]></title><description><![CDATA[<p dir="auto">How exactly would I do that? I’m still trying to learn javascript.   I’ve watched several videos and most of it has not clicked yet.</p>
]]></description><link>https://forum.magicmirror.builders/post/57328</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/57328</guid><dc:creator><![CDATA[wegz15]]></dc:creator><pubDate>Thu, 23 May 2019 01:06:49 GMT</pubDate></item><item><title><![CDATA[Reply to centering image with a colspan = 2 on Wed, 22 May 2019 23:43:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/wegz15" aria-label="Profile: wegz15">@<bdi>wegz15</bdi></a> wrap that cell in a div, which is 3 wide, the center the 2 cell image in the div</p>
]]></description><link>https://forum.magicmirror.builders/post/57327</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/57327</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Wed, 22 May 2019 23:43:03 GMT</pubDate></item></channel></rss>