无标签文本CSS变色实现实例页面

回到相关文章 »

效果:

原始标签效果

  • 选项1
  • 选项2
  • 选项3
  • 选项4
  • 选项5

CSS处理后

  • 选项1
  • 选项2
  • 选项3
  • 选项4
  • 选项5

代码:

CSS代码:
.wonder {
    padding-left: 0;
    margin: 0;
    list-style-type: none;
    color: #eee;
    box-shadow: 0 .6px, 0 -0.6px;
    -webkit-text-fill-color: #333;
}
.wonder li {
    line-height: 2.75rem;
    padding-left: 1rem;
    background-color: #fff;
    isolation: isolate;
    position: relative;
}
.wonder li:not(:last-child)::after {
    content: '';
    display: block;
    border-top: 1px solid;
    transform: scaleY(0.51);
    margin-top: -1px;
}
.wonder [type=radio] {
    -webkit-appearance: none;
    appearance: none;
    all: initial;
    position: absolute; left: 0;
    width: 100%; height: 100%;
}
.wonder [type=radio]:active {
    background: linear-gradient(#bbb1, #bbb1);    
}
.wonder :checked {
    color: #009FF1;        
}
.wonder :checked::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0; right: 1rem;
    width: .6125rem; height: .325rem;
    margin: auto;
    border-left: 2px solid;
    border-bottom: 2px solid;
    transform: rotate(-45deg);
}
.wonder :checked::after {
    content: '';
    position: absolute;
    left: 0; top: 0; right: 0; bottom: 0;
    background-color: currentColor;
    mix-blend-mode: lighten;
}
HTML代码:
<h4>原始标签效果</h4>
<ul>
    <li><input type="radio" name="item" checked>选项1</li> 
    <li><input type="radio" name="item">选项2</li> 
    <li><input type="radio" name="item">选项3</li> 
    <li><input type="radio" name="item">选项4</li> 
    <li><input type="radio" name="item">选项5</li> 
</ul>
<h4>CSS处理后</h4>
<ul class="wonder">
    <li><input type="radio" name="item" checked>选项1</li> 
    <li><input type="radio" name="item">选项2</li> 
    <li><input type="radio" name="item">选项3</li> 
    <li><input type="radio" name="item">选项4</li> 
    <li><input type="radio" name="item">选项5</li> 
</ul>