用html写网页的时候发现我设置的颜色和Chrome浏览器显示的颜色不同,主要原因在目前的html5已经不兼容之前html用bgcolor
参数来设置颜色,而需要使用css的方式来设置背景颜色。
原来html设置背景色的方式:
<body bgcolor="#74759b">
应该显示的颜色:
实际chrome显示的颜色:(非常迷惑)
虽然没有报错,但是有如下警告(Visual Studio Code作为IDE):
Background color for the document. This method is non-conforming, use CSS background-color property on the element instead.
现在改为:
<body style="background-color:#74759b">
成功显示正确的颜色, 并且VSCode中在代码中会有色彩块预览颜色:
本文地址:https://blog.csdn.net/m0_45338067/article/details/109243532
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
网友评论