Use CSS to make a span not clickable

后端 未结 7 2203
无人及你
无人及你 2020-12-08 03:55

    
    
    
        
                      
相关标签:
7条回答
  • 2020-12-08 04:35

    Using CSS you cannot, CSS will only change the appearance of the span. However you can do it without changing the structure of the div by adding an onclick handler to the span:

    <html>
    <head>
    </head>
    <body>
    <div>
    <a href="http://www.google.com">
      <span>title<br></span>
      <span onclick='return false;'>description<br></span>
      <span>some url</span>
    </a>
    </div>
    </body>
    </html>
    

    You can then style it so that it looks un-clickable too:

    <html>
    <head>
         <style type='text/css'>
         a span.unclickable  { text-decoration: none; }
         a span.unclickable:hover { cursor: default; }
         </style>
    </head>
    <body>
    <div>
    <a href="http://www.google.com">
      <span>title<br></span>
      <span class='unclickable' onclick='return false;'>description<br></span>
      <span>some url</span>
    </a>
    </div>
    </body>
    </html>
    
    0 讨论(0)
提交回复
热议问题