Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Members,

I have this code to get the my specified header width using percentage where
CS
C#
//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
JavaScript
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.
JavaScript
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
Posted
Updated 1-Oct-15 15:19pm
v4

You can add a class like:

CSS:

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:

JavaScript
DivHR.className = DivHR.className + " new-width";


Hope this helps!
 
Share this answer
 
#yourDivId{ width: calc(100% - 16px)}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900