通过CSS定位元素 [英] Position element through css

查看:88
本文介绍了通过CSS定位元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码的哪一部分是错误的,我不断收到无效的参数

what part of my code is wrong I keep getting invalid argument

我想将div元素放在文档窗口的左侧.

I want to position the div element outside the document window on the left.

jQuery(this).css({"left": (jQuery(document).css("left") - jQuery(form).width())});

推荐答案

document是HTMLDocument实例.它不是HTMLElement实例,因此没有CSS样式适用于它.因此,您无法从中读取任何left样式.您可以尝试使用document.documentElement(或$('html'))获取文档的根元素子级,但是我不确定您认为阅读其left样式会使用什么. (实际上:您将一无所获.)

document is the HTMLDocument instance. It's not an HTMLElement instance so no CSS styles apply to it. Consequently you can't read any left style from it. You can try document.documentElement (or $('html')) to get the root element child of the document, but I'm not sure what use you think reading its left style will be. (In reality: you'll get nothing.)

您是否真的要在浏览器窗口的外部处放置div?显然这是行不通的.窗口的整个想法是它会约束,裁剪和滚动其中的文档内容.

Are you really trying to position a div outside of the browser window? Obviously this cannot work; the whole idea of the window is that it constrains, clips and scrolls the document content inside it.

如果要在当前浏览器窗口之外显示内容,则必须window.open在基于当前窗口的屏幕位置(screenLeft/screen.left等)的位置弹出窗口.但是弹出式窗口在可用性方面存在许多严重缺陷,因此,浏览器限制了它们的使用.

If you wanted to display content outside of the current browser window you would have to window.open a pop-up at a position based on the current window's screen position (screenLeft/screen.left etc). But pop-ups have many serious usability drawbacks and browsers limit their use for this reason.

这篇关于通过CSS定位元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆