html插入自定义样式

html插入自定义样式
html_bf = BeautifulSoup(html, features='html.parser')

style = html_bf.find("style")
new_style = html_bf.new_tag("style")
new_style.append(
    "table tbody{display:block;height:400px;overflow-y:auto;-webkit-overflow-scrolling:touch;}table thead,tbody tr{display:table;width:100%;table-layout:fixed;background-color:CadetBlue;font-size:10px}table thead{width:calc(100%-1em)}table thead th{background-color: LightSalmon}")
style.insert_after(new_style)

divs = html_bf.select('.chart-container')
divs[1][
    "style"] = "width:900px;height:500px;position:absolute;top:30px;left:922px;border-style:dashed;border-width" \
               ":1px; "

divs[3][
    "style"] = "width:900px;height:500px;position:absolute;top:576px;left:923px;border-style:dashed;border-width" \
               ":1px; "
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页