0

No código atual quando clico no checkbox o hover é ativado para as letras e para o background estou tentando, fazer esse mesmo efeito porém com select, quando escolher uma opção do select ativar o hover, como posso fazer isto?

h1{
  color: #fff;
  text-align: center;
  font-size: 40px;
  font-weight: 100;
}

h2{
  color: #fff;
  font-weight: 400;
  font-size: 20px;
  line-height: 30px;
}

ul{
  list-style: none;
  margin: 0;
  padding: 0;
}

.steps{
  width: 656px;
  top: 15%;
  left: 0px; 
  right: 0px;
  margin: 0px auto;
}

input[type=checkbox] {
  display: none;
}

.ui-sortable-placeholder{
  border: 1px dotted #fff;
  padding: 30px 20px;
  position: relative;
}

.ui-sortable-placeholder:after{
  content: "Place me here. Pretty Please  :3";
  position: absolute;
  top: 30%;
  left: 0;
  right: 0;
  margin: auto;
  color: #fff;
  text-align: center;
}


label{
  background: #34495E;
  height: 69px;
  width: 100%;
  display: block;
  border-bottom: 1px solid #2C3E50;
  color: #fff;
  text-transform: capitalize;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.7s ease;
  position: relative;
  padding: 5px 5px 5px 70px;
  box-sizing: border-box;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
}


label h2 span{
  display: block;
  font-size: 15px;
  text-transform: capitalize;
  font-weight: normal;
  color: #bdc3c7;
}

label:before{
  content:"";
  width: 19px;
  height: 19px;
  border: 1px solid #416282;
  display: block;
  position: absolute;
  border-radius: 100%;
  right: 20px;
  top: 30%;
  transition: border 0.7s ease;
  z-index: 9999;
}

label:after{
  content: "";
  width: 60px;
  height: 68px;
  background: #2C3E50;
  
  left: 0;
  top: 0;
}


#label-1:checked ~ label[for=label-1],
#label-2:checked ~ label[for=label-2],
#label-3:checked ~ label[for=label-3],
#label-4:checked ~ label[for=label-4],
#label-5:checked ~ label[for=label-5]{
  background: #2C3E50;
  border-bottom: 1px solid #34495E;
  color: #1ABC9C;
}

#label-1:checked ~ label[for=label-1] h2,
#label-2:checked ~ label[for=label-2] h2,
#label-3:checked ~ label[for=label-3] h2,
#label-4:checked ~ label[for=label-4] h2,
#label-5:checked ~ label[for=label-5] h2{
  color: #1ABC9C;
}
#label-1:checked ~ label[for=label-1] h2 span,
#label-2:checked ~ label[for=label-2] h2 span,
#label-3:checked ~ label[for=label-3] h2 span,
#label-4:checked ~ label[for=label-4] h2 span,
#label-5:checked ~ label[for=label-5] h2 span{
  color: #1ABC9C;
}

#label-1:checked ~ label[for=label-1]:before,
#label-2:checked ~ label[for=label-2]:before,
#label-3:checked ~ label[for=label-3]:before,
#label-4:checked ~ label[for=label-4]:before,
#label-5:checked ~ label[for=label-5]:before{
  background: url("https://designmodo.github.io/Flat-UI/images/todo/done.png") no-repeat center center;
  border: 1px solid #1abc9d;
}

li:first-child label{
  height: 94px;
  text-transform: uppercase;
  font-size: 15px;
  border-left: 8px solid #f87c85;
  padding-top: 3%;
}


li:first-child label:before{
  top: 40%;
}

li:first-child label:after{
  height: 149px;
}

li:nth-child(2) label{
  border-right: 8px solid #feb47f;
}

li:nth-child(3) label{
  border-right: 8px solid #3498db;
}

li:nth-child(4) label{
  border-right: 8px solid #b985ea;
}

li:last-child label{
  border-right: 8px solid #43d6b0;
}
<div class="container">
  <h4>Final das vendas em 31 de Dezembro</h4>
  <div class="steps">
    <ul id="sortable">
        <li>
          <input id='label-1' type='checkbox'/>
          <select  id='label-1'>
            <option value="">1</option>
            <option value="">2</option>
            <option value="">3</option>
            <option value="">4</option>
          </select>
            <label for='label-1'>
              <h2>Lorem ipsum<span>Lorem ipsum</span></h2>   
            </label>
        </li>
      </ul>
  </div>
</div>

1 Resposta 1

0

Você pode incluir um escutador para o select e aplicar checked ao input checkbox:

$('select').on('change', function(){
   $('#label-1').prop('checked', true);
});

Nota: não use dois ids iguais para mais de um elemento. O código irá sempre considerar o primeiro da página, além de ser uma má pratica. Mais info sobre id no MDN.

Veja funcionando:

$('select').on('change', function(){
   $('#label-1').prop('checked', true);
});
h1{
  color: #fff;
  text-align: center;
  font-size: 40px;
  font-weight: 100;
}

h2{
  color: #fff;
  font-weight: 400;
  font-size: 20px;
  line-height: 30px;
}

ul{
  list-style: none;
  margin: 0;
  padding: 0;
}

.steps{
  width: 656px;
  top: 15%;
  left: 0px; 
  right: 0px;
  margin: 0px auto;
}

input[type=checkbox] {
  display: none;
}

.ui-sortable-placeholder{
  border: 1px dotted #fff;
  padding: 30px 20px;
  position: relative;
}

.ui-sortable-placeholder:after{
  content: "Place me here. Pretty Please  :3";
  position: absolute;
  top: 30%;
  left: 0;
  right: 0;
  margin: auto;
  color: #fff;
  text-align: center;
}


label{
  background: #34495E;
  height: 69px;
  width: 100%;
  display: block;
  border-bottom: 1px solid #2C3E50;
  color: #fff;
  text-transform: capitalize;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.7s ease;
  position: relative;
  padding: 5px 5px 5px 70px;
  box-sizing: border-box;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
}


label h2 span{
  display: block;
  font-size: 15px;
  text-transform: capitalize;
  font-weight: normal;
  color: #bdc3c7;
}

label:before{
  content:"";
  width: 19px;
  height: 19px;
  border: 1px solid #416282;
  display: block;
  position: absolute;
  border-radius: 100%;
  right: 20px;
  top: 30%;
  transition: border 0.7s ease;
  z-index: 9999;
}

label:after{
  content: "";
  width: 60px;
  height: 68px;
  background: #2C3E50;
  
  left: 0;
  top: 0;
}


#label-1:checked ~ label[for=label-1],
#label-2:checked ~ label[for=label-2],
#label-3:checked ~ label[for=label-3],
#label-4:checked ~ label[for=label-4],
#label-5:checked ~ label[for=label-5]{
  background: #2C3E50;
  border-bottom: 1px solid #34495E;
  color: #1ABC9C;
}

#label-1:checked ~ label[for=label-1] h2,
#label-2:checked ~ label[for=label-2] h2,
#label-3:checked ~ label[for=label-3] h2,
#label-4:checked ~ label[for=label-4] h2,
#label-5:checked ~ label[for=label-5] h2{
  color: #1ABC9C;
}
#label-1:checked ~ label[for=label-1] h2 span,
#label-2:checked ~ label[for=label-2] h2 span,
#label-3:checked ~ label[for=label-3] h2 span,
#label-4:checked ~ label[for=label-4] h2 span,
#label-5:checked ~ label[for=label-5] h2 span{
  color: #1ABC9C;
}

#label-1:checked ~ label[for=label-1]:before,
#label-2:checked ~ label[for=label-2]:before,
#label-3:checked ~ label[for=label-3]:before,
#label-4:checked ~ label[for=label-4]:before,
#label-5:checked ~ label[for=label-5]:before{
  background: url("https://designmodo.github.io/Flat-UI/images/todo/done.png") no-repeat center center;
  border: 1px solid #1abc9d;
}


.ativardvd{
  color: #1ABC9C;
}

.ativardvd:before{
   
  background: url("https://designmodo.github.io/Flat-UI/images/todo/done.png") no-repeat center center;
  border: 1px solid #1abc9d;
}


li:first-child label{
  height: 94px;
  text-transform: uppercase;
  font-size: 15px;
  border-left: 8px solid #f87c85;
  padding-top: 3%;
}


li:first-child label:before{
  top: 40%;
}

li:first-child label:after{
  height: 149px;
}

li:nth-child(2) label{
  border-right: 8px solid #feb47f;
}

li:nth-child(3) label{
  border-right: 8px solid #3498db;
}

li:nth-child(4) label{
  border-right: 8px solid #b985ea;
}

li:last-child label{
  border-right: 8px solid #43d6b0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class="container">
  <h4>Final das vendas em 31 de Dezembro</h4>
  <div class="steps">
    <ul id="sortable">
        <li>
          <input id='label-1' type='checkbox'/>
          <select  id='label-1'>
            <option value="">1</option>
            <option value="">2</option>
            <option value="">3</option>
            <option value="">4</option>
          </select>
            <label for='label-1'>
              <h2>Lorem ipsum<span>Lorem ipsum</span></h2>   
            </label>
        </li>
      </ul>
  </div>
</div>

1
  • A entendi, o valeu de novo...haha
    – Henrique
    27/11/2017 às 1:17

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .