html中一句话一部分变颜色,仅对HTML元素的一部分进行颜色

  • Post author:
  • Post category:其他


我想创建一个背景股利。考虑这个HTML:

Here’s some of my interesting text

​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

有了这个CSS:

#outer-container {

height: 300px;

width: 300px;

border: 1px solid black;

position: relative;

overflow: hidden;

}

#container-background {

position: absolute;

top: 0px;

left: 0px;

background-color: #FF0000; /* Use background-image or whatever suits you here */

width: 50%; /* Your width */

height: 200px; /* Your height */

z-index: -1;

}​

要创建这样一个结果:

g1yQs.png