Align to center

1

I would like to know how I can centralize the chat.

<iframe src="https://www2.cbox.ws/box/?boxid=2392843&boxtag=uStqza"width="75%" height="450" allowtransparency="yes" frameborder="0" marginheight="0" marginwidth="0" scrolling="auto"></iframe>
    
asked by anonymous 04.04.2018 / 21:07

3 answers

1

Create a div , put the chat inside. In CSS you do:

#div
  margin: 0 auto;
}

In JavaScript you do:

function centraliza(){
  var div = document.getElemenById('div');
  div.style.marginTop = (window.innerHeight / 2) - (div.offsetHeight / 2) + 'px';
}

centraliza(); "You put this function on the onload of the page and / or onresize too"

    
04.04.2018 / 22:03
0

You can add style="margin: 0 auto; display: block;" to iframe :

<iframe style="margin: 0 auto; display: block;" src="https://www2.cbox.ws/box/?boxid=2392843&boxtag=uStqza"width="75%" height="450" allowtransparency="yes" frameborder="0" marginheight="0" marginwidth="0" scrolling="auto"></iframe>

Example:

<iframe style="margin: 0 auto; display: block;" src="https://www2.cbox.ws/box/?boxid=2392843&boxtag=uStqza"width="75%" height="450" allowtransparency="yes" frameborder="0" marginheight="0" marginwidth="0" scrolling="auto"></iframe>
    
04.04.2018 / 22:16
-1

Create a div or class and there in the css you put: example with class: no html:

<div class="chat">
<iframe src="https://www2.cbox.ws/box/?boxid=2392843&boxtag=uStqza"width="75%" height="450" allowtransparency="yes" frameborder="0" marginheight="0" marginwidth="0" scrolling="auto"></iframe>
</div>

no css:

.chat{
 position: absolute;
 left: 50%;
 top: 50%;

}
    
04.04.2018 / 21:53