Jump to content
  • Sign Up
  • 0

Как из ссылки сделать кнопки?


Katerina23
 Share

Question

Мне из ссылки нужно сделать такие кнопки как на картинке.

Соответственно нужно получить две ссылки одна активная подсвечивается определенным цветом, вторая не активная прозрачная не подсвечивается.

Screenshot.jpg

Значит здесь нужно применить два стиля. Наведение мышкой не подходит, так как, эти ссылки будут менять в зависимости от перехода на страницу.

Вот код примера здесь сделано на input’ах мне нужно тоже самое только на ссылках.

<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <title></title>
 <link rel="stylesheet" type="text/css" href="style.css"/>

</head>
<body>
<div id="test">
  <form>
    <p id="step1">
      <input name="tech" type="radio" value="computer" id="computer" checked>
      <label for="computer">computer</label>
    </p>
    <p id="step2">
      <input name="tech" type="radio" value="xbox2" id="xbox">
      <label for="xbox">xbox</label>
    </p>
    <p id="step3">
      <input name="tech" type="radio" value="playstation" id="playstation">
      <label for="playstation">playstation</label>
    </p>
    <p id="step4">
      <input name="tech" type="radio" value="Game" id="game">
      <label for="game">Game</label>
    </p>
    <p id="step5">
      <input name="tech" type="radio" value="TV" id="tv">
      <label for="tv">TV</label>
    </p>
  </form>
 
 </div> 

</body>
</html>

Стили:

input{
    display: none;
}

input + label{
    font-size: 14px;
    border: #9c94bb 1px solid;
    width: 130px;
    background-color: #ffffff;
    transition: background-color .3s;
    color: #000000;
    text-align: center;
    padding: 7px 0;
    display: inline-block;
    margin-right: 10px;
}

input:checked + label{
    background: #ece8ff;
}

form{
    display: flex;
}

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy