I'm building a chrome extension that uses HTML injection to insert my own DIV into a page. I want to resize it but I don't have access to the CSS. Is it possible to somehow force my div to resize it's width using HTML or javascript?
2 Answers
You can resize it using javascript like so:
document.getElementById('yourDivId').style.height = "500px";
document.getElementById('yourDivId').style.width = "500px";
You could also try setting or adding the height attribute via JavaScript as well.
document.getElementById('yourDivId').setAttribute("height", "500px");
document.getElementById('yourDivId').setAttribute("width", "500px");
Comments
It works with javascript or with inline css here's how to:
HTML:
<div id="div" style="width:20px;height:20px;"></div>
Javascript:
var a = document.getElementById('div');
a.style.width = '200px';
a.style.height = '200px';
1 Comment
Jay Harris
You should make the answer more specific to the question. ie remove the background color style.
style="height:100px"?