[英]css overflow is not working properly
So I am writing a script for a live drawing area. 所以我正在为一个实时绘图区写一个脚本。 It is a work in progress right now, but here is the css for the area: 这是一项正在进行的工作,但这里是该地区的css:
#canvas{
background-repeat: no-repeat;
cursor:none;
overflow:hidden !important;
margin-top:50px;
width:400px;
height:300px;
border:1px #000 solid;
}
Now clearly, with the important
tag on overflow:hidden
, anything outside the 400x300 box that has to do with drawing should not show, but it does!!! 现在很明显, overflow:hidden
的important
标签overflow:hidden
,400x300框外的任何与绘图有关的东西都不应该显示, 但确实如此!
here is a jsfiddle so you can see all the code! 这是一个jsfiddle,所以你可以看到所有的代码!
Just click on the thing at the top that says paintbrush and follow the instructions in the p
tag for drawing. 只需点击顶部显示画笔的东西,然后按照p
标签中的说明进行绘制。 Then go outside of the box and see how it continues to draw. 然后走出盒子,看看它是如何继续绘制的。
note: 注意:
I use $('#canvas').prepend(content)
to get the drawing into the drawing area, so it makes no sense that it would show up in areas outside it when there is an overflow:hidden
. 我使用$('#canvas').prepend(content)
来绘制绘图区域,因此当出现overflow:hidden
时,它会显示在它之外的区域是没有意义的overflow:hidden
。 any ideas? 有任何想法吗?
Weird , but it helps: add position:relative
to #canvas
stylesheet: 很奇怪,但它有帮助:添加position:relative
对于#canvas
样式表:
#canvas {
/* ... */
position: relative;
/* ... */
}
(JSFiddle: http://jsfiddle.net/HEnuj/7/ ) (JSFiddle: http : //jsfiddle.net/HEnuj/7/ )
I'm not CSS specialist so i have no logical explanation , except of something like " if some elements has position:absolute
relatively to their parent so parent must be position:relative
" , thats what i remember. 我不是CSS专家所以我没有合理的解释,除了“ 如果某些元素有position:absolute
相对于他们的父母所以父母必须position:relative
”,这就是我记得的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.