How to set <asp: Panel> width to 25% of the content size
3 answers
You can use jQuery for this:
Assuming that Panel1is the identifier of your panel, and the corresponding content container that you want to work matches Container1,
var dWidth = $('#Container1').width();
$('#Panel1').width(dWidth * 0.25);
Sets the width Panel1to 25% of the container you use.
, ( div - , )
+3
, JavaScript Jobe, :
var Element_Id = document.getElementById("Elem_Id"); // Element Id
var curr_Element_Width = parseInt(Element_Id.clientWidth); // parseInt is taking down our "px" string at the width.... look:
var curr_Element_Id_Width = 100px we need INT only!
we only need the number 100 so after parseInt its now 100 and not 100px we can't work with string and that is the reson we doing that,
Then you can use a function like this ...
function addWidth() {
Element_Id.style.width = (curr_Element_Width + 100) + 'px'; // after we change the width we add the "px" string again
}
here we work with Px, but you can do the same with% hope, it will help you have a good day.
-1