如何通过CSS或JavaScript在iframe中调整宽度和高度?

时间:2019-02-17 05:25:26

标签: javascript html css iframe

我尝试通过css进行操作,但是由于我无法在html中更改它而没有改变

.bootbox-body iframe {width: 100%; height: 100%; }
<div class="bootbox-body"><iframe  style="width:100%;height:30px;" src="https://www.youtube.com/embed/IOwom_Gp__Q" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

2 个答案:

答案 0 :(得分:0)

iFrame在某种意义上是特殊的,它的宽度和高度都作为“与样式分开”的属性。 例如

<iframe src="https://youtube.com" width="200" height="200"></iframe>

至少在大多数样式中,它与实际的CSS样式相当糟糕。

答案 1 :(得分:0)

尝试

from bisect import bisect
def get_xy(A):
    x = [210*4, 210*1, 210*2, 210*3]
    y = [275*5, 275*2, 275*3, 275*4, 275*5]
    a = bisect([1, 2, 3, 4], A%4)
    b = bisect([0.25, 1.25, 2.25, 3.25], (A/4)%4)
    return (x[a], y[b])

'''
#Output:
get_xy(32)
(840, 1375)

get_xy(34)
(420, 550)

get_xy(37)
(210, 825)
'''