如何在JS中使用px减去100%的标头宽度 [英] How do I substract a header width of 100% with px in JS
问题描述
嗨大家,
我有这个代码来获取我指定的标题宽度使用百分比
CS
// 脚本管理器设置(gridId,height,width,headerHeight ,isFooter)
ScriptManager.RegisterStartupScript(Page, this .GetType(), 键, < script> MakeStaticHeaderORSA( ' + Gridview1.ClientID + ',400,100,27,false);< /脚本>, false );
JS
< pre lang =Javascript> DivHeader.style.width =( parseInt (width) - 1 。< span class =code-digit> 67 )+ '
但不是减去1.67%我想替换它具有16px更具体:
我做了类似下面的事情,但它不起作用。
DivHR.style.width =((( parseInt (width))+ ' %') - ( 16 + px'));
请告知我如何使用100%宽度和 - px得到我理想的宽度:)提前感谢你可以添加一个类:
CSS:
。 new-width {
width : -moz- calc(100% - 16px);
width : -webkit- calc(100% - 16px);
width : calc(100% - 16px);
}
然后将该课程添加到DivHR,如:
DivHR.className = DivHR。 className + new-width;
希望这会有所帮助!
#yourDivId {width:calc(100% - 16px)}
Hi Members,
I have this code to get the my specified header width using percentage where
CS
//Script Manager to set the (gridId, height, width, headerHeight, isFooter)
ScriptManager.RegisterStartupScript(Page, this.GetType(), "Key", "<script>MakeStaticHeaderORSA('" + Gridview1.ClientID + "', 400, 100, 27, false); </script>", false);
JS
DivHeader.style.width = (parseInt(width) - 1.67) + '%';
However instead of subtracting 1.67% I would like to replace it with 16px to be more specific:
Which I did something like below but its not working.
DivHR.style.width = (((parseInt(width)) + '%') - (16 +'px'));
Please advice on how can I use the 100% width and - px to get my ideal width:) thanks in advance
You can add a class like:
CSS:
.new-width { width: -moz-calc(100% - 16px); width: -webkit-calc(100% - 16px); width: calc(100% - 16px); }
Then add that class to the DivHR like:
DivHR.className = DivHR.className + " new-width";
Hope this helps!
#yourDivId{ width: calc(100% - 16px)}
这篇关于如何在JS中使用px减去100%的标头宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!