我希望能够获取鼠标指针的当前位置,相对于我的窗体窗口所在的位置。因此,如果我将鼠标放在表单的左上角,它会给我 x=0 和 y=0 的 x 和 y 值,而表单本身可能位于屏幕中间。
另外我想设置鼠标的位置。
这如何在 C# 中完成?我正在使用 Windows 窗体应用程序。
我不是CSS专家,特别是当它定位时,我希望这个很容易解决.
这是我简化的HTML:
<body>
<div style="height:100%;width:100%;">
<div id="map" style="bottom:250px;height:100%;overflow:hidden;position:absolute;width:100%;">
<!-- The controls div does not render correctly. -->
<div id="controls" style="left:10px;position:absolute;top:10px;">
</div>
<!-- The legend and logos divs do render correctly. -->
<div id="legend" style="bottom:45px;left:10px;position:absolute;">
</div>
<div id="logos" style="bottom:5px;left:10px;position:absolute;">
</div>
</div>
<div id="search" style="bottom:0;height:250px;position:absolute;width:100%;">
</div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
"controls"div无法正确呈现.事实上,它根本不显示.如果我拿出"顶部:10px;" 样式,并将其替换为"bottom:400px;",它确实正确呈现.但这不是我想要的,因为如果用户调整浏览器窗口大小,"map"div的高度会被调整.我也不想使用JavaScript来定位div.
"图例"和"徽标"div都正确呈现.
我在Firefox中进行测试.
在我在Firefox,SeaMonkey,Chrome,Opera,Safari,Camino和IE8上为我的学校建立的一个小网站测试后,我发现我的网站绝对定位的div都非常一致.
但是,当我开始在IE6和7中测试该网站时,所有的div都不合适并且整个页面都很混乱.
我花了两个星期的谷歌搜索并试图弄清楚问题是什么,但我仍然找不到一致的方法来解决这个问题.
希望我已经足够清楚了,对不起,如果我的英语不是很好,这是我的第三语言.
如果您需要更多说明,请随时提出.
任何和所有的帮助表示赞赏.
感谢您的时间.
注意:如上所述,我知道有许多解决方案和类似的问题,但是,我找不到在这种情况下工作的问题.
更新:缩放属性修复了我一直遇到的大部分问题,hasLayout似乎是一个巨大的痛苦.谢谢Spudly和Patrik
我正在显示位置绝对的div.
.my_label{
list-style:none;
list-style-type:none;
position:absolute;
top:2px;
left:10px;
width:20px;
height:20px;
background-color:#FF1021;
}
Run Code Online (Sandbox Code Playgroud)
一旦我重新调整浏览器窗口的大小,所有这些div都保持在同一位置.而且他们不再是父母元素的绝对.我希望他们与周围的物体保持联系.我应该使用"相对"的位置还是有另一种方式?(也欢迎jQuery)
非常感谢
为什么Firefox 4绝对不像其他浏览器那样定位fieldset图例?
测试页面:
<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8"/>
<title>Test</title>
<style type="text/css">
*
{
margin: 0;
padding: 0;
}
body
{
font-family: Tahoma, Arial, sans-serif;
font-size: 62.5%;
}
#wrapper
{
margin: auto;
padding: 1em;
width: 720px;
}
form
{
width: 670px;
padding: 25px;
background-color: #ffffff; /* White */
color: #000000; /* Black */
border: 1px solid #cccccc; /* Gray */
font-size: 12px;
}
fieldset
{
position: relative;
border: 1px solid #cccccc; /* Gray */
padding: 25px 10px 5px …Run Code Online (Sandbox Code Playgroud) 您好我正在构建一个移动网页,其中我的内容只会滚动,我的页脚和标题位置:固定 - 我可以制作内容,使其不会在页眉或页脚下滚动,以便它只是滚动它自己DIV.
我想要这样做的原因是我将在我的页眉和页脚上有一些不透明度,如果内容滚动下来,它看起来不太好看.
下面是一个jsfiddle,我只是向你展示滚动的例子

我需要创建一个这样的页面.蓝色圆圈是主圆圈,绿色圆圈应放在主圆圈周围.绿色圆圈计数是随机的(大约0-10).所有绿色圆圈都用一条线连接到蓝色圆圈.
我知道在CSS中绘制圆圈.我需要知道,
是否可以使用CSS.如果不是这样的话?
谢谢.
我有一个图像里面的图层:
<div id="foo"><img src="url" /></div>
Run Code Online (Sandbox Code Playgroud)
它是固定的:
#foo {
position: fixed;
}
Run Code Online (Sandbox Code Playgroud)
但我也希望图层在页面中水平居中.所以我试过:http: //jsfiddle.net/2BG9X/
#foo {
position: fixed;
margin: auto
}
Run Code Online (Sandbox Code Playgroud)
和 http://jsfiddle.net/2BG9X/1/
#foo {
position: fixed;
left: auto;
}
Run Code Online (Sandbox Code Playgroud)
但不起作用.任何想法如何实现它?
在下面的代码中,如何将文本中心放置在其正上方的边框空间中,如下面的屏幕截图所示,"Some Text 1"和"Some Text 2"位于它们上方的边框空间的中心.
.Row {
display: table;
width: 100%;
table-layout: fixed;
border-spacing: 10px;
}
.Column {
display: table-cell;
background-color: red;
}
.Column:nth-child(1) {
width:20%;
}
.Column:nth-child(2) {
width:50%;
}
.Column:nth-child(3) {
width:30%;
}Run Code Online (Sandbox Code Playgroud)
<div class="Row">
<div class="Column">C1</div>
<div class="Column">C2</div>
<div class="Column">C3</div>
</div>Run Code Online (Sandbox Code Playgroud)
css-position ×10
css ×9
html ×5
css3 ×2
browser ×1
c# ×1
css-tables ×1
firefox ×1
firefox4 ×1
html-table ×1
jquery ×1
legend ×1
mobile ×1
position ×1