javascript - Add links to CSS :nth-child class -


i'm stuck on how assign links (internal .html links) .button:nth-child() class in css. way knew add links via <a href=""> in html, works first nth:child, can see. solution (including js), appreciated.

html

<input type="checkbox" name="check" id="check"/> <label for="check" id="tog"></label> <div id="menu">     <a href="index.html">         <span class="button"></span>     </a>     <span class="button"></span>     <span class="button"></span>     <span class="button"></span> </div> 

css

#check:checked ~ #menu .button:nth-child(1)  {     background-image: url("pictures/homeicon.png");     background-repeat:no-repeat;     background-position: center center;     background-size: cover;     top: 8.6%;     z-index: 100;     -webkit-transition: 0.1s ease;     -moz-transition: 0.1s ease;     transition: 0.1s ease; } #check:checked ~ #menu .button:nth-child(2)  {     background-image: url("pictures/portfolio.png");     background-repeat:no-repeat;     background-position: center center;     background-size: cover;     top: 17.1%;     z-index: 90;     -webkit-transition: 0.2s ease;     -moz-transition: 0.2s ease;     transition: 0.2s ease; } #check:checked ~ #menu .button:nth-child(3)  {     background-image: url("pictures/abouticon.png");     background-repeat:no-repeat;     background-position: center center;     background-size: cover;     top: 25.7%;     z-index: 80;     -webkit-transition: 0.3s ease;     -moz-transition: 0.3s ease;     transition: 0.3s ease; } #check:checked ~ #menu .button:nth-child(4)  {     background-image: url("pictures/connect.png");     background-repeat:no-repeat;     background-position: center center;     background-size: cover;     top: 34.2%;     z-index: 70;     -webkit-transition: 0.4s ease;     -moz-transition: 0.4s ease;     transition: 0.4s ease; } 

thanks much.

from understand of question, 1 way achieve adding simple javascript on each of "button".

<!doctype html>  <html>  <head>      <script src="jquery-3.2.1.min.js"></script>      <script src="test.js"></script>      <link rel="stylesheet" type="text/css" href="test.css">  </head>      <body>         <input type="checkbox" name="check" id="check"/>          <label for="check" id="tog"></label>          <div id="menu">          <a href="index.html">              <span class="button">button</span>          </a>          <span class="button" onclick="location.href='http://google.com';">button2</span>          <span class="button" onclick="location.href='http://yahoo.com';">button2</span>          <span class="button" onclick="location.href='http://duckduckgo.com';">button2</span>          </div>      </body>  </html>

the onclick="location.href='<some internal link>';" allows redirect want.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -