在div之外设置“关闭”按钮

时间:2022-10-01 19:42:49

I have login button that is getting a little bit outside of the border of a div, but when I try to make it the same in the code it doesn't work.

我有login按钮,它有点超出div的边框,但是当我尝试在代码中使用相同的按钮时,它就不能工作了。

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

Where I want it to be placed (The little image close-button): where it supposed to be placed http://oi60.tinypic.com/24azfow.jpg

我想把它放在哪里(小图片关闭按钮):它应该放在哪里http://oi60.tinypic.com/24azfow.jpg

Where it actually placed: where it actually placed, using the css code that I wrote. http://oi58.tinypic.com/11m8iee.jpg

它实际放置的位置:它实际放置的位置,使用我编写的css代码。http://oi58.tinypic.com/11m8iee.jpg

2 个解决方案

#1


8  

do not use float

不使用浮动

instead in your container div use

相反,在您的容器div中使用。

position :relative;

and in the close box div use these styles

在关闭框div中使用这些样式

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

(given the fact that if your close button is 30x30)

(如果你的关闭按钮是30x30)

#2


2  

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

将边距更改为-,例如:-20px;。这将使元素向右移动20px。

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

This problem occured once with me and the best way to fix it is by using negative margins.

这个问题在我身上出现过一次,最好的解决方法是使用负边距。

or you can use absolute positioning.

或者你可以用绝对定位。

position:absolute;
left:value;
top:value;

#1


8  

do not use float

不使用浮动

instead in your container div use

相反,在您的容器div中使用。

position :relative;

and in the close box div use these styles

在关闭框div中使用这些样式

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

(given the fact that if your close button is 30x30)

(如果你的关闭按钮是30x30)

#2


2  

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

将边距更改为-,例如:-20px;。这将使元素向右移动20px。

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

This problem occured once with me and the best way to fix it is by using negative margins.

这个问题在我身上出现过一次,最好的解决方法是使用负边距。

or you can use absolute positioning.

或者你可以用绝对定位。

position:absolute;
left:value;
top:value;