Is a shaped iframe possible?

2019-02-25 06:03发布

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?

标签: css html iframe
5条回答
叼着烟拽天下
2楼-- · 2019-02-25 06:40

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

查看更多
Deceive 欺骗
3楼-- · 2019-02-25 06:42

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.

查看更多
女痞
4楼-- · 2019-02-25 06:47

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.

查看更多
贼婆χ
5楼-- · 2019-02-25 06:54

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

查看更多
Fickle 薄情
6楼-- · 2019-02-25 06:55

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

查看更多
登录 后发表回答