How can I replace text with CSS?

前端 未结 21 2485
暗喜
暗喜 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:08

    I had an issue where I had to replace the text of link, but I couldn't use JavaScript nor could I directly change the text of a hyperlink as it was compiled down from XML. Also, I couldn't use pseudo elements, or they didn't seem to work when I had tried them.

    Basically, I put the text I wanted into a span and put the anchor tag underneath it and wrapped both in a div. I basically moved the anchor tag up via CSS and then made the font transparent. Now when you hover over the span, it "acts" like a link. A really hacky way of doing this, but this is how you can have a link with different text...

    This is a fiddle of how I got around this issue

    My HTML

    This is your link text
    This is your actual link

    My CSS

     div.field a {
         color: transparent;
         position: absolute;
         top:1%;
     }
     div.field span {
         display: inline-block;
     }
    

    The CSS will need to change based off your requirements, but this is a general way of doing what you are asking.

提交回复
热议问题