How can I replace text with CSS?

前端 未结 21 2175
暗喜
暗喜 2020-11-22 06:17

How can I replace text with CSS using a method like this:

.pvw-title img[src*=\"IKON.img\"] { visibility:hidden; }

Instead of ( img

21条回答
  •  盖世英雄少女心
    2020-11-22 07:05

    This is simple, short, and effective. No additional HTML is necessary.

    .pvw-title { color: transparent; }
    
    .pvw-title:after {
            content: "New Text To Replace Old";
            color: black; /* set color to original text color */
            margin-left: -30px;
            /* margin-left equals length of text we're replacing */
        }
    

    I had to do this for replacing link text, other than home, for WooCommerce breadcrumbs

    Sass/Less

    body.woocommerce .woocommerce-breadcrumb > a[href$="/shop/"] {
        color: transparent;
        &:after {
            content: "Store";
            color: grey;
            margin-left: -30px;
        }
    }
    

    CSS

    body.woocommerce .woocommerce-breadcrumb > a[href$="/shop/"] {
        color: transparent;
    }
    
    body.woocommerce .woocommerce-breadcrumb > a[href$="/shop/"]&:after {
        content: "Store";
        color: @child-color-grey;
        margin-left: -30px;
    }
    

提交回复
热议问题