私は Jquery を使用していますが、ホバー イベント中にその場で CSS 値を更新するのに問題があります。基本的に、一番下の小さな線を、長さをdivのサイズに合わせて拡大縮小したいと考えています。
問題のあるコードは次のとおりです。
$('.menu li').hover(function () {
left = Math.round($(this).offset().left - $('.menu').offset().left);
//find the current width of the div
var width_flux = $('.menu #box .head').html($(this).find('img').width());
//pass value to CSS
$('.menu #box .head').css('width', (parseInt(width_flux)) +'px');
$('#box').stop(false, true).animate({left: left},{duration:500, easing: style});
//if user click on the menu
});
および対応するcss
.menu #box .head {
background: url("http://whoisedward.com/img/bar.png");
height:3px;
width:1px;
color:#eee;
/* force text display in one line */
white-space:nowrap;
/* set the text position manually */
padding-left:4px;
padding-top:3px;
}