I wrote a web application for my own resource for my employees, and part of the basic template is a simple dialog box - a hidden div , between the body and header with the absolute position that appears when the button is pressed (another div ), displays content based on the clicked button and disappears when X is clicked in the corner. You know the routine.
Therefore, I suspect that I do not need to do this, but I found that I could not yet describe the CSS of the dialog box in the basic CSS template so that I could guarantee that its position on the screen is always more or less the same. It seems, instead, since the contents of the dialog box are resized to a page, this requires redefining the margin-left and margin-right dialog boxes on any given page.
For example, my basic css for the dialog box is like this, and it is loaded every time with the basic html template:
#dialogBox { position: absolute; border: 4px solid; border-radius: 15px; cursor: default; text-align:center; z-index:1000; padding: 10px 0 10px 0; font-size: 36px; }
Pay attention to the absence of the field - I did not find one value of the field that performs the task without causing a vicious discrepancy in the size of the dialog box for the contents inside. For example, on a page where it is assumed that the content will be large enough, I set the value as such:
#dialogBox { margin: 5% 10% 0 10%; }
If it is expected that the content will be much lighter, it seems that the margin should be set again on the next page that I load in order to circumvent visual fraud:
#dialogBox { margin: 5% 33% 0 33%; }
This is not a big deal, but it is repeated. I'm sure there is a better way to do this, so the div just expands naturally and maintains equal margin-left and margin-right on any given page, while maintaining the “Goldilocks” size for its content - not too big, not too small is always in order.
I understand that in some jQuery libraries there is an existing infrastructure for “beautiful” dialog boxes - they even drag the screen and do tricks, but this is just for my own website, an application, so I'm just not interested in that. It's also good to know how to create things yourself, isn't it? I'm a little new to this to trick and just steal a bunch of CSS, so I try to be honest with it.
If I left any code that relates to this problem, I am more than happy to change my post.
EDIT. I have two excellent answers to the question of placing a dialogBox in the containing div - and the only reason I didn’t accept them is simply because it looks like I might need to redefine the dimension aspects on each page, despite some one-and-one code. This is probably my mistake, because the information on different pages is slightly different, and I would like my users not to scroll the page if necessary. Setting the width of the dialog box on one page allows me to do this; I dunno, if left before CSS, will allow me to do this.
FINAL EDITING. I believe that the accepted answer is the best solution for my project.