以原型的方式,给string字符串类型添加方法,用于实现颜色值格式的转换:不习惯使用原型方法的,只要借鉴实现方法就好! 代码如下: var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/; /*RGB颜色转换为16进制*/ String.prototype.colorHex = function(){ var that = this; if(/^(rgb|RGB)/.test(that)){ var aColor = that.replace(/(?:\(|
1.十六进制换RGB 例: var color = '#69ad52' let r = parseInt(“0px” + color.slice(1, 3)) //105 let g = parseInt(“0px” + color.slice(3, 5)) //173 let b = parseInt(“0px” + color.slice(5, 7)) //82 2.RGB转十六进制 例: var color = 'rgb(105, 173,82)' let hex = "#"
ylbtech-CSS:CSS 文本格式 1.返回顶部 1. CSS 文本格式 文本格式 This text is styled with some of the text formatting properties. The heading uses the text-align, text-transform, and color properties. The paragraph is indented, aligned, and the space between characters