【发布时间】:2019-01-18 20:06:25
【问题描述】:
你好,我在 HTML 中有这段代码
<div class="box"><!-- a long text --></div>
.box 有 10 行内部文本
.box 的 CSS 是
.box{
width:200px;
height: initial;
overflow: auto;
min-height: 20px;
}
我想得到 .box 的高度, 我用这个
$('.box').css('height');
但是给我 0px
上面的代码是你更好理解的示例
我的元素的真实代码
<li> <p class="proSliderText">this is a p tag</p>
</li>
css
.proSliderText{
position: absolute;
top:50%;
left:50%;
margin-left:-15%;
min-height: 40px;
margin-top: -40px;
width:20%;
font-size: 4vw;
height: initial;
}
父标签 CSS
.proSlider li{
list-style-type: none;
position: absolute;
top:0;
left:0;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
【问题讨论】:
-
在我的回答中使用
clientHeight。