JSFiddle - React, Tailwind, and code Playground

by João Vitor Scheuermann

HTML

<div class="center" id="teste"></div>
<div class="center" id="teste2"></div>
<div class="center" id="teste3"></div>

CSS

#teste {  
    width:300px; 
    height:50px;
    background-color: black;
    padding: 10px;
    margin:10px;
 }
 
  #teste2 {  
    width:350px; 
    height:50px;
    background-color: black;
    padding: 10px;
    margin:10px;
 }
 
  #teste3 {  
    width:200px; 
    height:50px;
    background-color: black;
    padding: 10px;
    margin:10px;
 }

JavaScript

function centerObjects () {
var i;
for (i = 0; $(".center").eq(i).length !== 0;i++) {
 console.log($(".center").eq(i).width());
}

} 



(function () {
var height = screen.height;
var width  = screen.width;

var i;
for (i = 0; $(".center").eq(i).length !== 0;i++) {
 console.log($(".center").eq(i).width());
}
}())