I have been experimenting with positioning HTML elements using the position: fixed;
and right
CSS properties, as outlined in the MDN Web Docs. However, I have noticed that this approach does not work as expected when trying to position a dialog
element. While I found a workaround by using margin-left: auto
, I am left wondering why the dialog element does not stick to the right side like a regular div
. It seems to align correctly when positioned at the top
, bottom
, or left
. I am currently working with Chromium.
dialog,
div {
position: fixed;
right: 0;
margin: 0;
}
dialog {
/*margin-left: auto;*/
}
<dialog open>dialog</dialog>
<div>div</div>