ねえ、私は次のjsfiddle > Fiddleを持っていますが、それについて助けが必要です。
マウスをその上に置くと、静的な幅に拡張されますが、テキストの長さに応じて、内側のテキスト$('.inner').height()によって取得されます。
問題は、最後のテキストリスト項目を少し超えてしまい、メニューボックス内のテキストのいずれかをロールオーバーすると、少し上にスライドすることです。(1) スライドして元に戻り、(2) 箱の底にその高さのための余分なスペースがなくても、必要な正確な高さになるのを防ぐにはどうすればよいでしょうか?
JS:
$(document).ready(function() {
$('#menuSquare, .inner').mouseout(function() {
theMenu('close');
});
$('#menuSquare, .inner').mouseover(function() {
theMenu('open');
});
});
function theMenu(what2Do) {
if (what2Do == 'open') {
$('#menuSquare').stop().animate({
width: 190, //95
height: $('.inner').height(),
duration:900,
'padding-top' : 10,
'padding-right' : 10,
'padding-bottom' : 10,
'padding-left' : 10,
backgroundColor: '#fff',
opacity: 0.8
}, 1000,'easeOutCubic')
} else {
$('#menuSquare').stop().animate({
width: "20",
height: "20",
padding: '0px',
backgroundColor: '#e51937',
opacity: 0.8
}, 500,'easeInCirc')
}
}
HTML:
<div id="menuSquare" class="TheMenuBox" style="overflow: hidden; width: 20px; height: 20px; background-color: rgb(229, 25, 55); opacity: 0.8; padding: 0px;">
<div class="inner">
<p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Custom Homes');">Custom Homes</p>
<p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Full Service Hotels');">Full Service Hotels</p>
<p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Mixed Use');">Mixed Use</p>
<p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Office');">Office</p>
<p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Retail');">Retail</p>
<p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Select Service Hotels');">Select Service Hotels</p>
</div>
</div>