473,499 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Positioning of appended nodes

Claus Mygind
571 Contributor
I would like for the two child nodes in the code below to appear side by side. But in all my attempts they are stacked on top of each other.
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML>
  3.  <HEAD>
  4.  
  5. <SCRIPT LANGUAGE="JavaScript">
  6. <!--
  7. // Create a div to hold the control.
  8. var controlDiv = document.createElement('DIV');
  9.  
  10. // Set CSS styles for the DIV containing the control
  11. // Setting padding to 5 px will offset the control
  12. // from the edge of the map
  13. controlDiv.style.padding = '5px';
  14. controlDiv.style.borderStyle = 'ridge';
  15. controlDiv.style.width = '500px';
  16.  
  17. // Set CSS for the control border
  18. var controlMC = document.createElement('DIV');
  19. controlMC.style.position = 'relative';
  20. controlMC.style.width = '20%';
  21. controlMC.style.backgroundColor = 'white';
  22. controlMC.style.borderStyle = 'solid';
  23. controlMC.style.borderWidth = '2px';
  24. controlMC.style.cursor = 'pointer';
  25. controlMC.style.textAlign = 'center';
  26. controlMC.title = 'Click to set the map to Home';
  27. controlDiv.appendChild(controlMC);
  28.  
  29. // Set CSS for the control interior
  30. var controlText = document.createElement('DIV');
  31. controlText.style.fontFamily = 'Arial,sans-serif';
  32. controlText.style.fontSize = '12px';
  33. controlText.style.paddingLeft = '4px';
  34. controlText.style.paddingRight = '4px';
  35. controlText.innerHTML = 'Center';
  36. controlMC.appendChild(controlText);
  37.  
  38. //////////////////////////////////////////////////////////////
  39. // Set CSS for the control border
  40. var controlUI = document.createElement('DIV');
  41. controlUI.style.position = 'relative';
  42. controlUI.style.width = '20%';
  43. controlUI.style.backgroundColor = 'white';
  44. controlUI.style.borderStyle = 'solid';
  45. controlUI.style.borderWidth = '2px';
  46. controlUI.style.cursor = 'pointer';
  47. controlUI.style.textAlign = 'center';
  48. controlUI.title = 'Click to set the map to RoadMap';
  49. controlDiv.appendChild(controlUI);
  50.  
  51. // Set CSS for the control interior
  52. var controlText = document.createElement('DIV');
  53. controlText.style.fontFamily = 'Arial,sans-serif';
  54. controlText.style.fontSize = '12px';
  55. controlText.style.paddingLeft = '4px';
  56. controlText.style.paddingRight = '4px';
  57. controlText.innerHTML = 'Map';
  58. controlUI.appendChild(controlText);
  59.  
  60. function myload() {
  61. document.getElementById('myDiv').appendChild(controlDiv); 
  62. }
  63. //-->
  64. </SCRIPT> 
  65. </HEAD>
  66.  <BODY onload="myload()">
  67. <div id="myDiv">
  68. </div>
  69.  </BODY>
  70. </HTML>
  71.  
  72.  
Jun 21 '10 #1
6 1743
Dormilich
8,658 Recognized Expert Moderator Expert
<div>s always appear below each other unless you position them absolutely or cast them to inline elements (both is a CSS setting).
Jun 21 '10 #2
Claus Mygind
571 Contributor
@Dormilich
Can you give a simple example of "casting inline"?
Jun 21 '10 #3
Dormilich
8,658 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. display: inline;
mind that an inline element behaves differently from a block element in the text flow.
Jun 21 '10 #4
Claus Mygind
571 Contributor
@Dormilich
Just what I needed thanks. They are just buttons I want to add to the page.
Jun 21 '10 #5
Dormilich
8,658 Recognized Expert Moderator Expert
why not using <button> or <span>, they’re already inline elements.
Jun 21 '10 #6
Claus Mygind
571 Contributor
@Dormilich
I am playing around with google maps and following one of their examples for creating custom controls.

You example worked great in my html editor "editPlus" but not when I ran the code in FireFox. I suppose that is what you meant by "text behaves differently"?
Jun 21 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

9
32026
by: Bryan R. Meyer | last post by:
Hello Everyone, The problem of browser resizing has become an issue for me. While redesigning my webpage, I set the left and right margins to be auto so that my content would be centered. ...
4
2682
by: Jane Withnolastname | last post by:
I am trying to re-work an old site by replacing the html with css. On the main page, I have a logo image which I needed centred on the initial screen. I found the solution here:...
2
2114
by: Karuppasamy | last post by:
Hi I am using a variable of StringBuilder to form a string. After appending a string of value like this {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Verdana;}}
7
1839
by: fremenusul | last post by:
I know I have been asking LOTS of xml questions and I really apprecaite all the help. Here is my XML file <?xml version="1.0" encoding="utf-8" ?> <products> <!-- Repeat the structure below...
1
2793
by: Charles Harrison Caudill | last post by:
with tables there is a clean and algorithmic way to organize things, but with css which is, once you get it working, much cleaner, I have to tweak and patch and hope and pray and curse before...
1
1126
by: beanweed | last post by:
This is a problem with a ASP.NET application I am writing. The interface allows a user to manipulate an XML document. I have in my xmldocument .. . . <item id="1"> <parents />...
3
4016
by: thrill5 | last post by:
I have an xml document such as: <device> <element>first</element> <element>second</element> </device> I am using this as the source for an xslt transform that goes like <xsl:for-each...
2
4096
by: daz_oldham | last post by:
Hi Everyone I have an xml document, and for the purposes of my application, I am going to take a node of the xml (child), add a child to it and then store it into the database for later use. ...
6
2891
by: Mark | last post by:
hi, i'm trying to position something in the top right corner of a container, but i can't seem to figure out how to get it working. here's the html <div class='thumb'><a href='image.jpg'><img...
0
1055
by: Stephen Ward | last post by:
I have a simple little project open a xml file change a few nodes save the file, no big deal. The problem is that the doctype is getting modified when I save the file. So it looks like this:...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.