简体   繁体   中英

Why doesn't `iframe` auto margin center the iframe inside a div?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM