{"id":26772,"date":"2016-12-07T03:01:46","date_gmt":"2016-12-06T17:01:46","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=26772"},"modified":"2016-12-07T06:23:23","modified_gmt":"2016-12-06T20:23:23","slug":"html-div-overlay-jigsaw-talents-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/html-div-overlay-jigsaw-talents-primer-tutorial\/","title":{"rendered":"HTML Div Overlay Jigsaw Talents Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/div_overlay_navigation.html\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"HTML Div Overlay Jigsaw Talents Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/div_overlay_navigation.jpg\" title=\"HTML Div Overlay Jigsaw Talents Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">HTML Div Overlay Jigsaw Talents Primer Tutorial<\/p><\/div>\n<p>It&#8217;s not as if we haven&#8217;t talked about it before, as evidenced by <a title='HTML Textarea and Div Talents Primer Tutorial' href='#htadtpt'>HTML Textarea and Div Talents Primer Tutorial<\/a> as shown below, but we think the HTML <a target=_blank title='HTML div information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_div.asp'><i>div<\/i><\/a> element is hugely useful.  If you ever &#8230;<\/p>\n<ol>\n<li>surf the &#8220;net&#8221; &#8230; and &#8230;<\/li>\n<li>come across a website whose design appeals to you &#8230; then you discover &#8230;<\/li>\n<li>via the browser&#8217;s View -&gt; Page Source (or equivalent) functionality &#8230; that &#8230;<\/li>\n<li>most\/all of the webpage&#8217;s <i>document.body.<a target=_blank title='Information about innerHTML from w3schools' href='http:\/\/www.w3schools.com\/jsref\/prop_html_innerhtml.asp'>innerHTML<\/a><\/i> is made up of a &#8220;jigsaw&#8221; of HTML <i>div<\/i> element components\n<\/ol>\n<p> &#8230; you would not be alone. Personally, we think more in terms of HTML <a target=_blank title='HTML table information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_table.asp'><i>table<\/i><\/a> thoughts, &#8220;by design&#8221; default, as much as anything because of the horizontal alignment simplicity of the HTML <i>table<\/i> element, but even we recognize how good an HTML <i>div<\/i> &#8220;jigsaw&#8221; of a webpage can be, as much as anything because there is nothing stopping those HTML <i>div<\/i> &#8220;jigsaw&#8221; parts containing our favoured HTML <i>table<\/i> element content within them, as for today&#8217;s &#8220;proof of concept&#8221; web application we&#8217;ve created.<\/p>\n<p>This web application today features &#8230;<\/p>\n<ul>\n<li>aforesaid mentioned HTML <i>div<\/i> &#8220;jigsaw&#8221; (2D look as HTML code and a pile of pieces piled up in Z in 3D when displayed) parts makeup of the webpage&#8217;s document.body.innerHTML &#8230; combined with &#8230;<\/li>\n<li>&#8220;overlay&#8221; CSS and Javascript DOM logic to treat 3 major HTML <i>div<\/i> &#8220;jigsaw&#8221; parts as like 3 separate HTML webpages, but in the one webpage &#8230; two of the the CSS &#8220;overlay&#8221; usual suspects (no <i>opacity<\/i> needed today) coming into play were &#8230;<\/p>\n<ol>\n<li><a target=_blank title='CSS position:absolute information from w3schools' href='http:\/\/www.w3schools.com\/cssref\/pr_class_position.asp'>position:absolute<\/a> property<\/li>\n<li><a target=_blank title='CSS z-index information from w3schools' href='http:\/\/www.w3schools.com\/cssref\/pr_pos_z-index.asp'>z-index<\/a><\/li>\n<\/ol>\n<p> &#8230; effectively &#8230;<\/li>\n<li>acting like <a target=_blank title='Ajax information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Ajax_%28programming%29'>Ajax<\/a>, in navigational terms, in that we don&#8217;t leave the webpage we are on &#8230; yet &#8230;<\/li>\n<li>all the benefits of &#8220;overlay&#8221; design allows for the Javascript DOM dynamic manipulation (to the extent that they can even be &#8220;blanked&#8221; as necessary) and changing of any\/all of these 3 major HTML <i>div<\/i> &#8220;jigsaw&#8221; parts<\/li>\n<\/ul>\n<p>Today&#8217;s web application also uses HTML <a target=_blank title='HTML a tag information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_a.asp'><i>a<\/i><\/a> element links with an interesting interplay between the &#8230;<\/p>\n<ul>\n<li>CSS (complex) pseudo class selectors we talked about at <a target=_blank title='CSS and HTML Complex Pseudo Class Selectors Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/css-and-html-complex-pseudo-class-selectors-tutorial\/'>CSS and HTML Complex Pseudo Class Selectors Tutorial<\/a> <b>as in<\/b> &#8230;<br \/>\n<code><br \/>\n&lt;style&gt;<br \/>\na { cursor: pointer; text-decoration: underline; margin: 15px 15px 15px 15px; background-color: white; }<br \/>\na:hover { background-color: lightgreen; }<br \/>\n<b>a[title=\"1\"]:hover { background-color: yellow; }<br \/>\na[title=\"2\"]:hover { background-color: pink; }<br \/>\na[title=\"3\"]:hover { background-color: lightblue; }<\/b><br \/>\ntd { border: 50px solid red; }<br \/>\n&lt;\/style&gt;<br \/>\n<\/code><br \/>\n &#8230; and &#8230;<\/li>\n<li>Javascript DOM, <b>kicked off<\/b> by a <i>document.body<\/i> <a target=_blank title='Javascript event onload information from w3schools' href='http:\/\/www.w3schools.com\/tags\/ev_onload.asp'><i>onload<\/i><\/a> event (though we could easily have hardcoded it) that added HTML <i>a<\/i> link titles equivalent to their <i>innerHTML<\/i> (content) property values, in order to &#8220;hook into&#8221; the CSS (complex) pseudo class selectors above for a colour coded <a target=_blank title='Javascript event onmouseover information from w3schools' href='http:\/\/www.w3schools.com\/tags\/ev_onmouseover.asp'><i>onmouseover<\/i><\/a> feel for all those non-mobile platform users out there &#8230;<br \/>\n<code><br \/>\n<b><br \/>\nfunction ahelper() {<br \/>\n var a_s=document.getElementsByTagName('a');<br \/>\n for (var i_a_s=0; i_a_s&lt;a_s.length; i_a_s++) {<br \/>\n   if (('' + a_s[i_a_s].title) == '') {<br \/>\n     a_s[i_a_s].title=a_s[i_a_s].innerHTML;<br \/>\n   }<br \/>\n }<br \/>\n} <\/b><br \/>\n&lt;\/script&gt;<br \/>\n&lt;body style='background-color: yellow;' <b>onload='ahelper();'<\/b>&gt;<br \/>\n<\/code>\n<\/li>\n<\/ul>\n<p>This, then, is both an &#8220;overlay&#8221; scenario, and a webpage navigation design idea.  As a &#8220;proof of concept&#8221;, we don&#8217;t do much detail with the content but rest assured the <a target=_blank title='div_overlay_navigation.html' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/div_overlay_navigation.html_GETME'>div_overlay_navigation.html<\/a> HTML programming source control&#8217;s <a target=_blank title='div_overlay_navigation.html' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/div_overlay_navigation.html'>live run<\/a> can be used to spark your imagination in &#8220;finger on the keyboard&#8221; action, we hope, and try out some of the ideas for yourself, perhaps?!  Good luck, if so.<\/p>\n<hr>\n<p id='htadtpt'>Previous relevant <a target=_blank title='HTML Textarea and Div Talents Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/html-textarea-and-div-talents-primer-tutorial\/'>HTML Textarea and Div Talents Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.html\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"HTML Textarea and Div Talents Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.jpg\" title=\"HTML Textarea and Div Talents Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">HTML Textarea and Div Talents Primer Tutorial<\/p><\/div>\n<p>We faced a dilemma today with the name of our web application, and ended up with <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.html-GETME\" title='textarea_talent.html'>textarea_talent.html<\/a> (along with its business logic external Javascript <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.js_GETME\" title='textarea_talent.js'>textarea_talent.js<\/a>), but as the project went along we were torn towards a name of <i>div_talent.html<\/i> and <i>div_talent.js<\/i> as we shall explain below.<\/p>\n<p>We understand the great role the HTML <a target=_blank title='HTML textarea tag information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_textarea.asp'>textarea<\/a> element has in <a target=_blank title='Content Management System information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Content_management_system'>CMS<\/a> (Content Management Systems) work, and we illustrate this below with (a) WordPress (blog as an example) &#8230;<\/p>\n<p><img src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.jpeg'><\/img><\/p>\n<p>It&#8217;s crucial for getting HTML or non-caretted Text (that is internally turned into HTML behind the scenes) &#8230; via those <a target=_blank title='Excel Online Spreadsheet Monthly Planner Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/excel-online-spreadsheet-monthly-planner-primer-tutorial\/'>wonderful<\/a> <a target=_blank title='Tab navigation button or panel information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Tab_(GUI)'>tabs<\/a> &#8230; off the user and onto the MySql database, and then out to the client user as part of a webpage.  Out at that webpage, though, we&#8217;ve no doubt this content is embedded in an HTML <a target=_blank title='HTML div tag information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_div.asp'>div<\/a> element, the other &#8220;talent&#8221; here.<\/p>\n<p>But their strengths and weaknesses go like this, at least to us, in the limited HTML text view of things &#8230;<\/p>\n<table border=100>\n<tr>\n<th>Text Functionality Issue<\/th>\n<th>HTML Element Type<\/th>\n<th>Strength<\/th>\n<th>Weakness (where a &#8220;Yes&#8221; is like &#8230; &#8220;Oh No!&#8221;)<\/th<\/tr>\n<tr>\n<td rowspan=2>Display Monocolour Text<\/td>\n<td>Textarea<\/th>\n<td>Yes<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>Div<\/th>\n<td>Yes<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td rowspan=2>Display Editable Text<\/td>\n<td>Textarea<\/th>\n<td>Yes<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>Div<\/th>\n<td><\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<tr>\n<td rowspan=2>Display Multicolour Text<\/td>\n<td>Textarea<\/th>\n<td><\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>Div<\/th>\n<td>Yes<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<\/table>\n<p>Our web application today is like an inhouse version of (a web browser) View Page Source type of arrangement, but allowing, optionally, for the highlighting of words.  The &#8220;highlighting of words&#8221; functionality needed the HTML div element to come into the equation, otherwise the &#8220;talents&#8221; of an HTML textarea element would have sufficed, and are normally preferred, for those editing reasons.  By the way, an HTML textarea element given a <a target=_blank title='HTML textarea element readonly property' href='http:\/\/www.w3schools.com\/tags\/att_textarea_readonly.asp'><i>readonly<\/i><\/a> property stops the user changing an HTML textarea element&#8217;s contents, should that be what you require.<\/p>\n<p>Another issue came into play as a &#8220;subtheme&#8221; of today&#8217;s tutorial.  Are you aware that some HTML elements, such as &#8230;<\/p>\n<blockquote><p>\nTextarea elements do not, by default, inherit CSS styling settings of the webpage Body element\n<\/p><\/blockquote>\n<p> &#8230; which means, without Javascript DOM programmatic intervention the text shown in an HTML textarea element will differ greatly in its appearance to that of an HTML div element.  This annoyed us enough to warrant some research and development on this topic and found that the idea to have both HTML div and textarea elements to be mapped to the inherited look of the HTML body element, that you might attempt to do via CSS like &#8230;<\/p>\n<p><code><br \/>\n&lt;style&gt;<br \/>\ntextarea, div {<br \/>\n font-family: inherit;<br \/>\n font-size: inherit;<br \/>\n}<br \/>\n&lt;\/style&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; was not nearly so effective a thing to do, as to put in the hard yards to &#8220;purloin&#8221; the styling characteristics of one HTML element type and &#8220;slap&#8221; those characteristics, via Javascript DOM, onto the other HTML element type of interest, via code (snippet) like used today (with its &#8220;thank you&#8221; implied link), as per &#8230;<\/p>\n<p><code><br \/>\nfunction copyTextareaStyling() {<br \/>\n    var output = document.getElementById(\"tarea\"), divelem = document.getElementById(\"tareadiv\");<br \/>\n    if (divelem) { \/\/ thanks to ideas off <a target=_blank title='Useful link, thanks' href='http:\/\/stackoverflow.com\/questions\/12266320\/copy-div-content-to-textarea-or-text-with-the-same-font-family-style'>http:\/\/stackoverflow.com\/questions\/12266320\/copy-div-content-to-textarea-or-text-with-the-same-font-family-style<\/a><br \/>\n      divelem.style.fontFamily = window.getComputedStyle(output,null).fontFamily || output.style.fontFamily || output.currentStyle.getCurrentProperty('font-family');<br \/>\n      divelem.style.fontSize = window.getComputedStyle(output,null).fontSize || output.style.fontSize || output.currentStyle.getCurrentProperty('font-size');<br \/>\n      divelem.style.border = window.getComputedStyle(output,null).border || output.style.border || output.currentStyle.getCurrentProperty('border');<br \/>\n      divelem.style.padding = window.getComputedStyle(output,null).padding || output.style.padding || output.currentStyle.getCurrentProperty('padding');<br \/>\n      divelem.style.margin = window.getComputedStyle(output,null).margin || output.style.margin || output.currentStyle.getCurrentProperty('margin');<br \/>\n      divelem.style.overflow = window.getComputedStyle(output,null).overflow || output.style.overflow || output.currentStyle.getCurrentProperty('overflow');<br \/>\n    }<br \/>\n}<br \/>\n<\/code><\/p>\n<p> &#8230; via the wonders of the Javascript <a target=_blank title='window.getComputedStyle information' href='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\/getComputedStyle'>window.getComputedStyle()<\/a> method that we have mentioned before a few times at this <a target=_blank title='Search for window.getComputedStyle blog postings here' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/?s=window.getComputedStyle&#038;stype=Search'>blog<\/a>.<\/p>\n<p>Maybe you are a regular at this blog, and recognize the look of today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.html\" title='Click picture'>live run<\/a> web application?  Yes, a lot of the ideas emanating from <a target=_blank title='Legend for and from HTML Map Element Web Server Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/legend-for-and-from-html-map-element-web-server-tutorial\/'>Legend for and from HTML Map Element Web Server Tutorial<\/a> thread of blog postings went into the <a target=_blank title='Information about purloinment' href='http:\/\/www.yourdictionary.com\/purloinment'>&#8220;purloinment&#8221;<\/a> &#8230; <font size=1>nga, nga .. nga nga &#8230; ngaaa &#8230; it is a word<\/font> &#8230; exercise done on <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/legend_via_map.html------GETME\" title='legend_via_map.htm'>legend_via_map.htm<\/a>&#8216;s code <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.html-GETME\" title='textarea_talent.html'>in this way<\/a> mostly to do with the virtuous decision to hive off specific business logic to the external Javascript <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.js_GETME\" title='textarea_talent.js'>textarea_talent.js<\/a>.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d25195' onclick='var dv=document.getElementById(\"d25195\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/textarea\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d25195' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d26772' onclick='var dv=document.getElementById(\"d26772\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/div\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d26772' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s not as if we haven&#8217;t talked about it before, as evidenced by HTML Textarea and Div Talents Primer Tutorial as shown below, but we think the HTML div element is hugely useful. If you ever &#8230; surf the &#8220;net&#8221; &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/html-div-overlay-jigsaw-talents-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[69,2073,281,342,1596,354,576,1525,652,658,830,870,871,894,997,1986,1976,1238,1319,1496],"class_list":["post-26772","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-ajax","tag-alignment","tag-css","tag-div","tag-document-body-innerhtml","tag-dom","tag-html","tag-innerhtml","tag-javascript","tag-jigsaw","tag-navigation","tag-onload","tag-onmouseover","tag-overlay","tag-programming","tag-proof-of-concept","tag-pseudo-class","tag-table","tag-tutorial","tag-z-index"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/26772"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=26772"}],"version-history":[{"count":14,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/26772\/revisions"}],"predecessor-version":[{"id":26798,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/26772\/revisions\/26798"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=26772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=26772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=26772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}