Changing the href of an html tag with css

前端 未结 3 1794
轻奢々
轻奢々 2020-12-11 01:40

I need to change this A tag from

Contact

to



        
相关标签:
3条回答
  • 2020-12-11 02:15

    one solution is to hide a tag and put another

    <div id="tag1">
    <a href="#tag1">link1</a>
    <a href="#tag2">link2</a>
    </div>
    

    css :

    a[href="#tag1"] {
    display:block;
    }
    
    a[href="#tag2"] {
    display:none;
    }
    
    #tag1:target  a[href="#tag1"]{
     display:none;
    }
    
    #tag1:target  a[href="#tag2"]{
     display:block;
    }
    

    I use this method for responsive "buttons" of my menu bar

    0 讨论(0)
  • 2020-12-11 02:17

    CSS is for presentation and cannot be used to modify the HTML markup in the way you intend. You need JavaScript for this.

    It should be a fairly short script.

    0 讨论(0)
  • 2020-12-11 02:29

    CSS is display only, you cannot modify the document object model with it. Sorry, this cannot be done. I wish I had a better answer, but 'it cannot be done' is the only answer.

    0 讨论(0)
提交回复
热议问题