Make the close button outside the div

I have a login button that goes slightly beyond the boundaries of the div, but when I try to do the same in the code, it does not work.

.closeWindow{
    float: right;
    margin-left: 15px; /* width of the close button / 2 */
    margin-bottom: 15px; /* height of the close button / 2 */
}

Where I want to place it (small button to close the image): where it supposed to be placed

Where is it actually located: where it actually placed, using the css code that I wrote.

+4
source share
2 answers

do not use float

instead in your container div use

position :relative;

and in the closing box div use these styles

position: absolute;
top: -15px;
right: -15px;

(given that if your close button is 30x30)

+8
source

change the margin to minus, for example margin-left: -20px ;. this will make the element move 20px to the right.

margin-left: -40px;  /*moves 40px right*/
margin-bottom: -20px; /*moves 20px up*/

This problem occurred once with me, and the best way to fix it is to use negative fields.

.

position:absolute;
left:value;
top:value;
+2

Source: https://habr.com/ru/post/1544021/


All Articles