Is a shaped iframe possible?

2019-02-25 06:30发布

问题:

Is it possible to have an iframe in the shape of a hexagon or diamond or anything other than a rectangle or square?

Or possibly even a div?

回答1:

You could fake it with a CSS mask.

But portions of it will be obscured by it. You can't make the iframe render its contents inside of one of these shapes.



回答2:

You could set an iframe shape (or, rather, an iframe container shape) to something oval farily easy, however the problem with a diamond/hex shape is that you can't set any html element to render in that shape in the first place.

You could try using a mask as alex suggested.



回答3:

I think you have to use an image as a mask and then absolute position it



回答4:

Depending on what browsers you want to support, you can use border radius, transparency, and other tricks to create many shapes in css.



回答5:

No, it is not. There is no posibilites in HTML standard to do this. You can wrap iframe with DIV and get some effects like rounded corners only



标签: css html iframe