Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/398.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将标签的位置固定在鼠标上方_Javascript_Css_Label - Fatal编程技术网

Javascript 将标签的位置固定在鼠标上方

Javascript 将标签的位置固定在鼠标上方,javascript,css,label,Javascript,Css,Label,我有标签和使用JS我做标签要加粗,但当标签加粗是改变其他标签对象的位置,我想加粗标签在其相同的位置,而不改变或干扰其他标签 这是我的JS和标签代码 function changeCA() { document.getElementById("CA").style.border="solid 1px #464646"; document.getElementById("CA").style.fontWeight="bold"; document.getElement

我有标签和使用JS我做标签要加粗,但当标签加粗是改变其他标签对象的位置,我想加粗标签在其相同的位置,而不改变或干扰其他标签 这是我的JS和标签代码

function changeCA()
    {
    document.getElementById("CA").style.border="solid 1px #464646";
    document.getElementById("CA").style.fontWeight="bold";
    document.getElementById("CA").style.color="white";
    //document.getElementById("CA").style.marginLeft="-15px"; 
    //document.getElementById("CA").style.paddingRight="-5px"; 

    document.getElementById("CA").style.borderTopColor="#dd4b39";
    document.getElementById("CA").style.borderLeftColor="#464646";
    document.getElementById("CA").style.borderRightColor="#464646";
    document.getElementById("CA").style.borderBottomColor="#464646";
    }

<asp:Label ID="CA" runat="server"   Font-Names="Arial" Font-Size="10pt" ForeColor="#CCCCCC"   Text="Current Activities" Style="padding-top:4px; padding-bottom:4px; margin:0px 1px 0 0;"          onmouseover="ChangeCA()"></asp:Label>   
function changeCA()
{
document.getElementById(“CA”).style.border=“solid 1px#4646”;
document.getElementById(“CA”).style.fontwweight=“bold”;
document.getElementById(“CA”).style.color=“白色”;
//document.getElementById(“CA”).style.marginLeft=“-15px”;
//document.getElementById(“CA”).style.paddingRight=“-5px”;
document.getElementById(“CA”).style.borderTopColor=“#dd4b39”;
document.getElementById(“CA”).style.borderLeftColor=“#464646”;
document.getElementById(“CA”).style.borderRightColor=“#4646”;
document.getElementById(“CA”).style.borderBottomColor=“#4646”;
}

任何人都可以帮助我确定当标签变为粗体时的位置。为标签设置一个固定的宽度。这也意味着您需要将标签的显示设置为block或inline block。

FYI,如果您在CA对象中添加了一个类,然后将所有这些样式放入该类的CSS文件中,您的代码会更干净。函数的主体可以是一行。您也不需要设置所有四种边框颜色。您可以在此处查看一个简化示例:。