【发布时间】:2015-10-01 11:48:50
【问题描述】:
我有这段代码可以使用百分比来获取我指定的标题宽度
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) + '%';
但是,我不想减去 1.67%,而是更具体地用 16px 替换它: 我在下面做了类似的事情,但它不起作用。
DivHR.style.width = (((parseInt(width)) + '%') - (16 +'px'));
请建议我如何使用 100% 宽度和 - px 来获得理想的宽度, 提前致谢
【问题讨论】:
-
你返回的宽度是多少?
-
你为什么不只用 css 做:
#yourDivId{ width: calc(100% - 16px)} -
您好,很抱歉我丢失了代码。我的宽度是 100,输入来自 CS 谢谢
-
感谢 1|13v!欢呼
标签: javascript html css asp.net