I have a div
and an iframe
inside it. I want to make the iframe to be center. The margin: auto
works for other dom but not the iframe. Is there a way for me to center the iframe inside the div?
div { height: 300px; width: 300px; display: flex; } iframe { margin: auto; height: 50px; width: 50px; display: block; }
<div> <iframe src="http://localhost:8080" align="right" /> </div>
Add ;important;
to your iframe css tag
iframe {
margin: auto !important;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.