我意外地发现了这一点scrollTop
,并且scrollLeft
即使元素存在,元素也能正常工作overflow: hidden
.可以依赖这种行为吗?
据推测,对于没有滚动条的元素,scrollTop和scrollLeft应该为零,并且在这些元素上设置它们应该没有效果.
如果我用CSSOM添加了样式,insertRule
我注意到了两件事.
在Firebug中查看时,添加的样式不会出现在html中.
如果附加样式标记(例如:从头部移动到主体)到另一个元素(在Firefox和Chrome中发生),则添加的样式不起作用.
如果在添加标记后添加样式,则它们可以正常工作.他们仍然没有在Firebug中展示.附加表格时必须重新分配(重新?),这使得它看起来更奇怪.
因为没有在Firebug中显示,它可能是Firebug的怪癖,但是没有动态添加的常规样式显示出来.
对于追加后不起作用的样式我想知道这是否是标准,因为这发生在Firefox和Chrome中.看看标准,我没有看到任何关于这一点.除非我只是不理解他们.
var style = document.createElement('style'),
sheet = style.sheet;
document.head.appendChild(style);
//When line 6 is un-commented the styles work
//if line 8 is also commented out.
//document.querySelector('.container').appendChild(style);
//Get the sheet when line 6 is un-commented
sheet = style.sheet
sheet.insertRule('.test{color: red}');
document.querySelector('.container').appendChild(style);
//styles don't apply after the previous line
Run Code Online (Sandbox Code Playgroud)
为清晰起见编辑:
如果您<style></style>
在<head></head>
html中添加标签,则可以应用样式style.sheet.insertRule(styleString)
,并且添加的样式将适用于该文档.
如果您已经是附加<style></style>
的<head></head>
像<head><style></style></head>
,并试图追加<style></style>
其他地方像<div><style></style></div>
所有样式都将丢失,而不要再次申请.
这是正常的吗?
代码流程:
作品:
<style>
任何地方style.sheet.insertRule(styleString) …
现在我可以创建一个终端,但输出不用作命令.它只是将字符串打印到虚拟终端.
from gi.repository import Gtk, GObject, Vte
class TheWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="inherited cell renderer")
self.set_default_size(400, 200)
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
v = Vte.Terminal()
#v.connect ("child-exited", lambda term: gtk.main_quit())
length = len("echo \"string\"\n")
v.feed("echo \"string\"\n", length)
box.pack_start(v, True, True, 0)
self.add(box)
Run Code Online (Sandbox Code Playgroud)
我尝试使用这里的文档 http://developer.gnome.org/vte/0.30/,但是我在解决这些问题时遇到了一些麻烦.我根本找不到关于vte for python gtk3的任何文档.
主要是我只想弄清楚如何在虚拟终端中获取命令提示符,以便它接受来自python gtk3接口内部的命令.