0

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?

1
  • 3
    can you not resize the div with inline css? ie. style="height:100px"? Commented Dec 11, 2014 at 2:32

2 Answers 2

1

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");
Sign up to request clarification or add additional context in comments.

Comments

0

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

You should make the answer more specific to the question. ie remove the background color style.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.