【问题标题】:How do I substract a header width of 100% with px in JS?如何在 JS 中用 px 减去 100% 的标题宽度?
【发布时间】: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


【解决方案1】:

下面的代码是我的问题的解决方案,谢谢

  #yourDivId{ width: calc(100% - 16px)}

【讨论】:

    猜你喜欢
    • 2011-09-29
    • 1970-01-01
    • 2012-04-29
    • 1970-01-01
    • 2011-06-03
    • 2013-03-10
    • 1970-01-01
    • 1970-01-01
    • 2011-07-10
    相关资源
    最近更新 更多