确定。因此,要获得clientWidth,您必须添加代码
#menuSystem a{
position: absolute;
height: auto;
width: auto;
font-size: 15px;
}
您需要这样做,甚至有资格确定客户端宽度。我想要做的是将与链接相关的描述气泡的左边距设置为链接的clientWidth的长度。但是,当我添加"绝对" css属性链接,他们搞砸了。 链接应该如何,但不是泡沫: 泡沫应该如何,但不是链接 所以这是我的JavaScript函数
function hover(x){
var id = x;
var hoverBubble = document.getElementById(id);
var concat = ["menuLink", id];
var menuId = concat.join("");
var link = document.getElementById(menuId);
var linkWidth = link.clientWidth + 1;
hoverBubble.style.display = "inline";
hoverBubble.style.marginLeft = linkWidth + 'px';
}
答案 0 :(得分:0)
还有其他方法可以“启用”clientWidth
,例如float:left
或display:inline-block
。
这有帮助吗?