JSFiddle - React, Tailwind, and code Playground
CSS
.exampleElement {
padding: 5px;
margin: 6px;
}
.exampleElement .exampleP {
padding: 20px;
margin: 6px;
}
JavaScript
function exampleElement(caption, content) {
this.caption = caption;
this.content = content;
this.rootElement = document.createElement("div");
}
exampleElement.prototype.constructElement = function() {
var otherElement = document.createElement("p");
this.rootElement.className = "exampleElement";
this.rootElement.textContent = this.caption;
otherElement.className = "exampleP";
otherElement.textContent = this.content;
this.rootElement.appendChild(otherElement);
/*I need to know size of the otherElement here*/
/*here goes code adding stuff into rootElement*/
};
window.onload = function() {
var ex = new exampleElement("Hello", "Here's text");
ex.constructElement();
document.body.appendChild(ex.rootElement);
};