我先让你看看代码,然后告诉你我的问题是什么:
Tinkerbin:http://tinkerbin.com/x8iGCFsZ
<style>
div.container{
height: 200px;
width: 200px;
background-color:red;
margin-top: 10px;
}
div.subContainer{
position: relative;
text-align: center;
}
div.inner{
position: absolute;
background-color:yellow;
width: 150px;
}
</style>
<div class="container">
<div class="subContainer">
<div class="inner">bananas for breakfast</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
因此,根据教科书,text-align: center;当应用于父元素时,如果它们具有,则仅将其子元素居中display: inline;.
因此,正如您所期望的那样,由于<div>默认显示设置为block(display:block;),因此text-align: center;应用于父级div.subContainer不会对其子级执行任何操作div.inner.
到目前为止一切都很好.没什么奇怪的.
当我尝试使用<span>而不是<div>在.inner元素上时,我的问题引起了我的绝对定位(position: absolute;) - 正如你所知,强制将显示从默认内联更改为阻止.
看一看:
<style>
div.container{
height: 200px;
width: 200px;
background-color:red;
margin-top: 10px; …Run Code Online (Sandbox Code Playgroud) 如果您尝试运行以下代码,您将看到
(![]+[])[+1]返回"a";
(![]+[])[+2]返回"l";
(![]+[])[+3]返回"s".
等等.为什么?
我正在使用 konvajs,需要一些帮助!
假设我需要一个可在复杂形状内拖动的图像。
我想知道是否可以使用 Konva.Group 而不是 ClipFunc 来使用遮罩,或者将遮罩图像转换为 canvas-clip-path 并将其与 ClipFunc 一起使用!
像这样:屏蔽可拖动