I have an iframe surrounded by div element and I am simply trying to position it always in the center. here is my jsfiddle effort : jsfiddle
and tr
one solution is:
div {
text-align:center;
width:100%;
}
iframe{
width: 200px;
}
edit: vertical align added
div {
text-align: center;
width: 100%;
vertical-align: middle;
height: 100%;
display: table-cell;
}
.iframe{
width: 200px;
}
div,
body,
html {
height: 100%;
width: 100%;
}
body{
display: table;
}
using fiddle: http://jsfiddle.net/h9gTm/867/display: flex on the div {
display: flex;
align-items: center;
justify-content: center;
}