Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #31729

Re: Is there a quick way (simple syntax) to place a new DOM element vertically below instead of Horizontal (to the right)?

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Is there a quick way (simple syntax) to place a new DOM element vertically below instead of Horizontal (to the right)?
Date 2016-11-16 13:38 +0100
Organization PointedEars Software (PES)
Message-ID <40009118.fMDQidcC6G@PointedEars.de> (permalink)
References <520f9d34-7e8b-42f3-b35a-7868ed850dba@googlegroups.com> <1b8x6zxmkoqsv.fmhgem6julyi.dlg@40tude.net>

Show all headers | View raw


JJ wrote:
^^
Your real name belongs there.

> On Tue, 15 Nov 2016 18:04:56 -0800 (PST), justaguy wrote:
>> [Is there a quick way (simple syntax) to place a new DOM element 
>> vertically below instead of Horizontal (to the right)?]
>> span or div. Or finding x, y coordinates and then placing a new element
>> at such coordinates is the only option to do it?
>> Table's TR seems one option.
> 
> There's no quick/simple way.

IBTD.

> If you just want to do everything as simple as possible, use a library.

This problem can probably be solved using CSS only:

  .foo {
    position: relative;
  }

  .foo .bar {
    position: absolute; /* or “fixed” */
    bottom: 0;
  }

Scripting it would not require a library:

  ancestor.style.position = "relative";

  var element = document.createElement("baz");
  element.style.position = "absolute"; /* or "fixed" */
  element.style.bottom = "0";
  element.appendChild(document.createTextNode("blub"));

  parentNode.appendChild(element);

(possibility: ancestor === parentNode)

Alternatively, one can set the “className” property of the relevant element 
objects, or use the “classList” property to add() class names, and apply the 
stylesheet above by making it the content of a newly created and inserted 
“style” element:

  var style = document.createElement("style");
  style.type = "text/css";
  style.appendChild(document.createTextNode(".foo …"));

  (document.head || document.getElementsByTagName("head")[0])
    .appendChild(style);

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Is there a quick way (simple syntax) to place a new DOM element vertically below instead of Horizontal (to the right)? justaguy <lichunshen84@gmail.com> - 2016-11-15 18:04 -0800
  Re: Is there a quick way (simple syntax) to place a new DOM element vertically below instead of Horizontal (to the right)? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-11-15 23:49 -0800
    Re: Is there a quick way (simple syntax) to place a new DOM element vertically below instead of Horizontal (to the right)? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-11-16 11:07 +0100
  Re: Is there a quick way (simple syntax) to place a new DOM element vertically below instead of Horizontal (to the right)? JJ <jj4public@vfemail.net> - 2016-11-16 19:05 +0700
    Re: Is there a quick way (simple syntax) to place a new DOM element vertically below instead of Horizontal (to the right)? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-11-16 13:38 +0100
      Re: Is there a quick way (simple syntax) to place a new DOM element vertically below instead of Horizontal (to the right)? justaguy <lichunshen84@gmail.com> - 2016-11-16 18:18 -0800
    Re: Is there a quick way (simple syntax) to place a new DOM element vertically below instead of Horizontal (to the right)? justaguy <lichunshen84@gmail.com> - 2016-11-16 18:18 -0800

csiph-web