Using Javascript:
We need this function to return width and height.
function viewport() {
var e = window, a = 'inner';
if (!('innerWidth' in window )) {
a = 'client';
e = document.documentElement || document.body;
}
return { width : e[ a+'Width' ] , height : e[ a+'Height' ] };
}
we get the value of the width by using viewport().width.
Example:
//use this if viewport width is less than or equal to 768px
if(viewport().width <= 768){
search_form.css({left: "125px", top: "50px"});
}
Got this function somewhere in Stackoverflow