How to add a unified header to multiple subpages in HTML?
P粉293341969
P粉293341969 2023-09-03 12:51:38
0
1
496
<p>I'm developing a navigation bar system and would like to know how to make the subpages change but the title of the original page remain. (I'm using repl.it, so be advised). </p> <p>I haven't placed anything in the folder yet. I also want it not to change color when I hover over an item with "active" class (the gray one). </p> <p> <pre class="brush:css;toolbar:false;">@import url('https://fonts.googleapis.com/css2?family=Roboto Mono:wght@700&display=swap'); html body{ background: #0E1212; } ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: none; font-family: 'Roboto Mono', monospace; } li { float: left; } li a { display: block; color: #DBDBDB; text-align: center; padding: 14px 16px; text-decoration: none; } li a:hover { color: #682AE9; animation-name: example; animation-duration: 0.5s; animation-iteration-count: 1; animation-fill-mode: forwards; } .active { color: #808080; } @keyframes example { 0% {color: #DBDBDB;} 100% {color: #622cd8;) }</pre> <pre class="brush:html;toolbar:false;"><!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"> <link rel="stylesheet" href="home.css"> <script src='script.js'> </script> <title>Home</title> </head> <body> </head> <body> <ul id='menu'> <li><a class="active" href="#home" id="home">.home()</a></li> <li><a class="inactive" href="#news">.about()</a></li> <li><a class="inactive" href="#contact">.stuff()</a></li> <li><a class="inactive" href="#about">.apply()</a></li> </ul> </body> </html></pre> </p>
P粉293341969
P粉293341969

reply all(1)
P粉642436282

To answer the part of your question about keeping the color of the active class constant on hover, what I did was create another @keyframe such that at 0% and They all remain gray at 100%. Then I use transition: 0.5s; to make the animation transition of the color change smooth.

    @import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@700&display=swap');
html body {
  background: #0E1212;
}

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: none;
  font-family: 'Roboto Mono', monospace;
}

li {
  float: left;
}

li a {
  display: block;
  color: #DBDBDB;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

li a:hover {
  color: #682AE9;
  transition: 0.5s;
  animation-name: example;
  animation-duration: 0.5s;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
}

.active {
  color: #808080;
}

.active:hover {
  color: #808080;
}

@keyframes .active {
  0% {
    color: #808080;
  }
  100% {
    color: #808080;
    )
  }
 
  @keyframes example {
    0% {
      color: #DBDBDB;
    }
    100% {
      color: #622cd8;
      )
    }
<!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">
  <link rel="stylesheet" href="home.css">
  <script src='script.js'>
  </script>
  <title>Home</title>
</head>

<body>



  </head>

  <body>

    <ul id='menu'>
      <li><a class="active" href="#home" id="home">.home()</a></li>
      <li><a class="inactive" href="#news">.about()</a></li>
      <li><a class="inactive" href="#contact">.stuff()</a></li>
      <li><a class="inactive" href="#about">.apply()</a></li>
    </ul>

  </body>

</html>

As you can see, when you hover over the first link (i.e. active state), it is still gray and the other links turn purple within 0.5s.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!