如何使子 div = 父级的高度,其中具有 display:inline-block 和未指定的高度?
由于与 tumblr 自定义怪癖相关的原因,我必须将按钮的背景与父按钮分开。
这是 html:
<a href="link">
<div class="innerNest"> //I'm guessing we need this to bring the two divs to T:0 L:0
<div class="buttonText">{tumblr variable}</div>
<div class="buttonBG"></div>
</div>
</a>
这是我坚持使用的 css,至少对于标签:
a{
display: inline-block;
}
我在这里制作了一个非常具有描述性的 jsfiddle:http://jsfiddle.net/hVuaf/35/
注意:像这样(用于演示的内联 CSS目的):
<a href="link" style="background-color:#fff;display:inline-block">Link</a>
但我就是不能,这与我想要控制 Tumblrs 自定义主题编辑面板中分配的变量颜色有关。基本上它支持山的颜色,但我需要使用 rgba,而不是 #,因此我需要分离按钮的组件。
谢谢。
I have to separate the background of a button from the parent, for reasons related to the tumblr customisation quirks.
Here is the html:
<a href="link">
<div class="innerNest"> //I'm guessing we need this to bring the two divs to T:0 L:0
<div class="buttonText">{tumblr variable}</div>
<div class="buttonBG"></div>
</div>
</a>
This is the css I'm stuck with, at least for the tag:
a{
display: inline-block;
}
I've made a very descriptive jsfiddle here: http://jsfiddle.net/hVuaf/35/
NB: It's a no brainer to just go like this for eg (inline CSS for demo purposes):
<a href="link" style="background-color:#fff;display:inline-block">Link</a>
But i just can't, it's got to do with me wanting control over variable assigned colours in Tumblrs customised theme edit panels. Basically it supports colours to the hills, but i need to work with rgba, not #, hence my need to separate the components of the button.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这就是你所追求的吗?
http://jsfiddle.net/cdj2L/
基本上,我已将锚点设置为position:relative,然后里面的文字只是标准的。然后我将背景设置为绝对值,宽度/高度为 100%,填充锚点。最后,z-index 整理了分层。
希望有帮助:)
Is this what you are after?
http://jsfiddle.net/cdj2L/
Basically, I've set the anchor to position:relative and then the text inside is just standard. Then the background I've set to absolute and width/height are 100%, filling the anchor. Finally, a z-index sorts out the layering.
Hope that helps :)
这是您要找的吗?我删除了 bg 元素,只使用容器来设置背景。
http://jsfiddle.net/mrtsherman/hVuaf/43/
Is this what you are looking for? I removed the bg element and just used the container to set the background.
http://jsfiddle.net/mrtsherman/hVuaf/43/
你可以这样做吗:http://jsfiddle.net/hVuaf/45/
Can you do this: http://jsfiddle.net/hVuaf/45/