设置高度:100%在我的标签元素上不工作 [英] Setting height: 100% on my label element doesn't work

查看:95
本文介绍了设置高度:100%在我的标签元素上不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在标签中设置 height:100%; ,但它没有工作。为什么不呢?

I tried to set height: 100%; in the label, but it didn't work. Why not?

.field label {
    color:#3E3E3E;
    font-weight:bold;
    width:80px;
    display:block;
    float:left;
    margin-top:5px;
    margin-left:3px;
    height:100%; /* <-- doesn't work */
}
.field {
    display:block;
    margin-bottom:9px;
    background:none;
    border:none;
}

<div class="field large">
    <label>Textarea</label>
    <textarea></textarea>
</div>

推荐答案

你的身高设置为100%,但100%的是什么?它总是该元素的父元素,所以父元素的高度设置为?如果它没有设置为任何东西,那么浏览器没有引用。

You have height set to 100% but 100% of what? It's always the parent of that element so what is the parent's height set to? If it's not set to anything then the browser has nothing to reference.

这篇关于设置高度:100%在我的标签元素上不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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