Answers for "set div position according to screen"

CSS
2

align div to center of screen

div.the-center-div {
	margin: 0 auto;
}
Posted by: Guest on September-28-2020
0

div element position in screen

function offset(el) {    var rect = el.getBoundingClientRect(),    scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,    scrollTop = window.pageYOffset || document.documentElement.scrollTop;    return { top: rect.top + scrollTop, left: rect.left + scrollLeft }}
// example usevar div = document.querySelector('div');var divOffset = offset(div);console.log(divOffset.left, divOffset.top);
Posted by: Guest on May-26-2020

Code answers related to "set div position according to screen"

Browse Popular Code Answers by Language