我想在 HTML
中的窗口中添加一个关闭按钮,并且我希望该按钮 float 在 winodw 上,如本例所示:http://sandbox.scriptiny.com/tinybox2/ (第二个例子)
所以我在我的 HTML
中添加了一个 div
代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html"; charset=ISO-8859-1">
</head>
<body class="din">
<h1>MyWindow</h1>
<div id="hello"></div>
<div id="coucou"></div>
<img id="close" src="img/close.png" value="Close Window" onclick="closeWindow()"></img>
</body>
</html>
在我的 CSS 中:
#close {
position: fixed;
top: 1em;
right: 1em;
cursor: pointer;
z-index: 1000;
}
按钮出现在右上角的窗口中,但不完全在顶 Angular 。我应该添加什么才能使它恰好出现在拐 Angular 处?
最佳答案
它并没有完全出现在右上角,因为你已经将顶部和右侧的样式设置为非零的值:
#close {
position: fixed;
top: 0; /* <--- set to zero, 1em = the inherited font size, which will offset it */
right: 0;/* <--- set to zero, 1em = the inherited font size, which will offset it */
cursor: pointer;
z-index: 1000;
}
关于html - 将元素放在窗口的右上角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24821032/