i would like to know if there's a way to convert pixel to percent... I have a code which i get the value of full width successfully, but the only thing to keep the object in center, i must need to use percent.
Here's what i use on getting the value of width which i need to convert after to percent.
$(document).ready(function(){
var sp = $('.slide'),
winWidth = $('#slides').width();
console.log(winWidth);
sp.css('width', winWidth);
});
Thanks for the help.
Here's the updated fiddle link. *note: what i wanted here was to set the ".slide" container become fluid to make the object still in center spot. Feel free to modify my fiddle. Right now im using my given jQuery code to get the exact width of the "#slide" in percent to pixel ('.slide'). Then as of that, try to resize your browser to see the output of the slide frame. Im using SlidesJS plugin FYI.
percent = ($("#your_element").width() / $("#some_parent_id").width()) * 100
Where $("#your_element")
is element you want to count width in %
, where $("#some_parent_id")
is element relative to which you want to count width.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With