user1161310
user1161310

Reputation: 3139

resizing div width using HTML

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?

Upvotes: 0

Views: 75

Answers (2)

baao
baao

Reputation: 73291

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';

Upvotes: 0

mwilson
mwilson

Reputation: 12970

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");

Upvotes: 1

Related Questions