css 如何改变悬停?

mcvgt66p  于 2022-12-05  发布在  其他
关注(0)|答案(4)|浏览(164)

我想改变的字体大小和颜色的a当我悬停在p。它是行不通的。也许有一个简单的解决方案,但我挣扎了几个小时以来。
如果任何人没有到复杂的链接相关的这个主题,我也会很高兴

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      p:hover div nav a {
        color: blue;
        font-size: 22px;
      }
    </style>
  </head>
  <body>
    <div>
      <nav>
        <p>Ceramics</p>
        <a href="">One</a>
        <a href="">Two</a>
        <a href="">Three</a>
      </nav>
    </div>
  </body>
</html>
kokeuurv

kokeuurv1#

你好,我得到了简单的解决方案给你.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
       
        
        p:hover + .hv {
        
        color: blue;
        font-size: 22px;
        
        }
        
    </style>
  </head>
  <body>
    <div>
      <nav>
        <p>Ceramics</p>
        <div class="hv">
        <a  href="">One</a>
        <a  href="">Two</a>
        <a  href="">Three</a>
        </div>
      </nav>
    </div>
  </body>
</html>
67up9zun

67up9zun2#

你好,好的,如果我可以得到你。你想得到

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
       
        
        .hv a:hover{
        
        color: blue;
        font-size: 22px;
        
        }
        
        
    </style>
  </head>
  <body>
    <div>
      <nav>
        <p>Ceramics</p>
        <div class="hv">
        <a  href="">One</a>
        <a  href="">Two</a>
        <a  href="">Three</a>
        </div>
      </nav>
    </div>
  </body>
</html>
5n0oy7gb

5n0oy7gb3#

请尝试以下内容:p:hover, a:hover {color: blue;font-size: 22px;}

eh57zj3b

eh57zj3b4#

您的CSS选择器p:hover div nav a不正确。这将引用悬停在<p/>中的<div/>中的<nav/>中的<a/>。您可以通过我在下面所做的更改来修复此问题。

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      nav p { /*selects all hovered <p/> within a <nav/>*/
        color: blue;
        font-size: 22px;
      }
    </style>
  </head>
  <body>
    <div>
      <nav>
        <p>Ceramics</p>
        <a href="">One</a>
        <a href="">Two</a>
        <a href="">Three</a>
      </nav>
    </div>
  </body>
</html>

相关问题