评级星星设计变成垂直

问题描述 投票:0回答:2

我在创建一个评级界面时遇到问题,该界面将要求用户对网站进行评级(通过单击星星)并添加评论。 星星变成了垂直的而不是水平的,如链接的图片所示,我尝试了很多,但我不会工作。

 Stars became in vertical Screenshot

/* New Rating CSS code */

.Cont {
  position: absolute;
  width: 633px;
  height: 438px;
  left: 413px;
  top: 252px;
  background: #F1F2F0;
  padding: 25px;
  border-radius: 9px;
  box-shadow: 4px 4px 2px #F1F2F0(230, 254, 164);
}

.cont {
  position: absolute;
  width: 20px;
  background: #f1f2f0;
  padding: 10px 10px;
  border: 1px solid gray;
  border-radius: 10px;
  /* display: inline-block; */
  align-items: center;
  justify-content: center;
  /* flex-direction: row-reverse; */
}

.cont .post {
  display: none;
}

.cont .text {
  font-size: 25px;
  color: #000;
  font-weight: 500;
}

.cont .edit {
  position: absolute;
  right: 10px;
  top: 5px;
  font-size: 16px;
  color: #000;
  font-weight: 500;
  cursor: pointer;
}

.cont .edit:hover {
  text-decoration: underline;
}

.cont .star-widget input {
  transform: rotate(90deg);
  display: none;
}

.star-widget label {
  font-size: 40px;
  position: relative;
  color: #fff;
  padding: 10px;
  float: right;
  transition: all 0.2s ease;
}

input:not(:checked)~label:hover,
input:not(:checked)~label:hover~label {
  color: #fd4;
}

input:checked~label {
  color: #fd4;
}

input#rate-5:checked~label {
  color: #fe7;
  text-shadow: 0 0 20px #952;
}

.container form {
  display: none;
}

input:checked~form {
  display: block;
}

form header {
  width: 100%;
  font-size: 25px;
  color: #fe7;
  font-weight: 500;
  margin: 5px 0 20px 0;
  text-align: center;
  transition: all 0.2s ease;
}

form .textarea {
  height: 100px;
  width: 100%;
  overflow: hidden;
}

form .textarea textarea {
  height: 130px;
  position: absolute;
  width: 588px;
  top: 230px;
  outline: #777;
  color: gray;
  border: 1px solid gray;
  background: #fff;
  padding: 10px;
  font-size: 16px;
  resize: none;
  text-align: center;
  justify-content: center;
}

.textarea textarea:focus {
  border-color: #000;
}

form .btn {
  position: absolute;
  height: 30px;
  width: 590px;
  top: 380px;
  left: 23px;
}

form .btn button {
  height: 100%;
  width: 100%;
  border: 0px solid #000;
  outline: none;
  background: #c5e8b4;
  color: #000;
  font-size: 17px;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
}

form .btn button:hover {
  background: #c5e8b4;
}
<div class="Cont">
  <form action="" method="post">
    <div class="cont">
      <div class="post">
        <div class="text">Success </div>
        <div class="edit">edit</div>
      </div>

      <div class="star-widget">
        <input type="radio" name="Rate" id="rate-5" value="5">
        <label for="rate-5" class="fas fa-star" value="rate-5"></label>

        <input type="radio" name="Rate" id="rate-4" value="4">
        <label for="rate-4" class="fas fa-star" value="rate-4"></label>

        <input type="radio" name="Rate" id="rate-3" value="3">
        <label for="rate-3" class="fas fa-star" value="rate-3"></label>

        <input type="radio" name="Rate" id="rate-2" value="2">
        <label for="rate-2" class="fas fa-star" value="rate-2"></label>

        <input type="radio" name="Rate" id="rate-1" value="1">
        <label for="rate-1" class="fas fa-star" value="rate-1"></label>
      </div>


    </div>
    <div dir="ltr" class="textarea">
      <textarea name="Comment" cols="30" placeholder="Describe your experince in the website"></textarea>
    </div>
    <div class="btn">
      <button type="submit" name="submit">Send</button>
    </div>


  </form>

</div>

javascript html css rating stars
2个回答
0
投票

/* New Rating CSS code */
.Cont{
  position: absolute;
  width: 633px;
  height: 438px;
  left: 413px;
  top: 252px;
  background: #F1F2F0;
  padding: 25px;
  border-radius: 9px;
  box-shadow: 4px 4px 2px #F1F2F0(230, 254, 164);  
}
.cont{
  position: absolute;
  width: 20px;
  background: #f1f2f0;
  padding: 10px 10px;
  /*border: 1px solid gray;*/
  border-radius: 10px;
  /* display: inline-block; */
  align-items: center;
  justify-content: center;
  /* flex-direction: row-reverse; */
}
.cont .post{
  display: none;
}
.cont .text{
  font-size: 25px;
  color: #000;
  font-weight: 500;
}
.cont .edit{
  position: absolute;
  right: 10px;
  top: 5px;
  font-size: 16px;
  color: #000;
  font-weight: 500;
  cursor: pointer;
}
.cont .edit:hover{
  text-decoration: underline;
}
.cont .star-widget input{
  transform:rotate(90deg);
  display: none;
}
.star-widget label{
  font-size: 40px;
  position: relative;
  color: #fff;
  padding: 10px;
  float: right;
  transition: all 0.2s ease;
}
input:not(:checked) ~ label:hover,
input:not(:checked) ~ label:hover ~ label{
  color: #fd4;
}
input:checked ~ label{
  color: #fd4;
}
input#rate-5:checked ~ label{
  color: #fe7;
  text-shadow: 0 0 20px #952;
}

.container form{
  display: none;
}
input:checked ~ form{
  display: block;
}
form header{
  width: 100%;
  font-size: 25px;
  color: #fe7;
  font-weight: 500;
  margin: 5px 0 20px 0;
  text-align: center;
  transition: all 0.2s ease;
}
form .textarea{
  height: 100px;
  width: 100%;
  overflow: hidden;

}
form .textarea textarea{
  height: 130px;
  position: absolute;
  width: 588px;
  top:230px;
  outline:#777;
  color: gray;
  border: 1px solid gray;
  background: #fff;
  padding: 10px;
  font-size: 16px;
  resize: none;
  text-align: center;
  justify-content: center;
}
.textarea textarea:focus{
  border-color: #000;
}
form .btn{
  position: absolute;
  height: 30px;
  width: 590px;
  top:380px;
  left: 23px;

}
form .btn button{
  height: 100%;
  width: 100%;
  border: 0px solid #000;
  outline: none;
  background: #c5e8b4;
  color: #000 ;
  font-size: 17px ;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
}
form .btn button:hover{
  background: #c5e8b4;
}

/* use reverse flexbox to take advantage of flex-direction: reverse */
.star-rating {
  display: flex;
  align-items: center;
  width: 160px;
  flex-direction: row-reverse;
  justify-content: space-between;
  margin: 40px auto;
  position: relative;
}
/* hide the inputs */
.star-rating input {
  display: none;
}
/* set properties of all labels */
.star-rating > label {
  width: 30px;
  height: 30px;
  font-family: Arial;
  font-size: 30px;
  transition: 0.2s ease;
  color: orange;
}
/* give label a hover state */
.star-rating label:hover {
  color: #ff69b4;
  transition: 0.2s ease;
}
.star-rating label:active::before {
  transform:scale(1.1);
}

/* set shape of unselected label */
.star-rating label::before {
  content: '\2606';
  position: absolute;
  top: 0px;
  line-height: 26px;
}
/* set full star shape for checked label and those that come after it */
.star-rating input:checked ~ label:before {
  content:'\2605';
}

@-moz-document url-prefix() {
  .star-rating input:checked ~ label:before {
  font-size: 36px;
  line-height: 21px;
  }
}  
<div class="Cont">
        <form action="" method="post">
            <div class="cont">
                <div class="post">
                    <div class="text">Success </div>
                    <div class="edit">edit</div>
                </div>
        
            <div class="star-rating">
      <input type="radio" name="stars" id="star-a" value="5"/>
      <label for="star-a"></label>

      <input type="radio" name="stars" id="star-b" value="4"/>
      <label for="star-b"></label>
  
      <input type="radio" name="stars" id="star-c" value="3"/>
      <label for="star-c"></label>
  
      <input type="radio" name="stars" id="star-d" value="2"/>
      <label for="star-d"></label>
  
      <input type="radio" name="stars" id="star-e" value="1"/>
      <label for="star-e"></label>
</div>

            
        </div>
        <div dir="ltr" class="textarea">
            <textarea name="Comment" cols="30" placeholder="Describe your experince in the website"></textarea>
          </div>
          <div  class="btn">
            <button type="submit" name="submit">Send</button>
          </div>


        </form>

    </div>

试试这个代码。


0
投票

您可以将每个标签和输入包装在一个 div 中,并将 star-widget 转换为 flex。像下面这样

/* New Rating CSS code */
.Cont{
  position: absolute;
  width: 633px;
  height: 438px;
  left: 413px;
  top: 252px;
  background: #F1F2F0;
  padding: 25px;
  border-radius: 9px;
  box-shadow: 4px 4px 2px #F1F2F0(230, 254, 164);  
}
.cont{
  position: absolute;
  background: #f1f2f0;
  padding: 10px 10px;
  border: 1px solid gray;
  border-radius: 10px;
  /* display: inline-block; */
  align-items: center;
  justify-content: center;
  /* flex-direction: row-reverse; */
}
.cont .post{
  display: none;
}
.cont .text{
  font-size: 25px;
  color: #000;
  font-weight: 500;
}
.cont .edit{
  position: absolute;
  right: 10px;
  top: 5px;
  font-size: 16px;
  color: #000;
  font-weight: 500;
  cursor: pointer;
}
.cont .edit:hover{
  text-decoration: underline;
}
.cont .star-widget {
  display: flex;
}
.cont .star-widget input{
  transform:rotate(90deg);
  display: none;
}
.star-widget label{
  font-size: 40px;
  position: relative;
  color: #fff;
  padding: 10px;
  float: right;
  transition: all 0.2s ease;
}
input:not(:checked) ~ label:hover,
input:not(:checked) ~ label:hover ~ label{
  color: #fd4;
}
input:checked ~ label{
  color: #fd4;
}
input#rate-5:checked ~ label{
  color: #fe7;
  text-shadow: 0 0 20px #952;
}

.container form{
  display: none;
}
input:checked ~ form{
  display: block;
}
form header{
  width: 100%;
  font-size: 25px;
  color: #fe7;
  font-weight: 500;
  margin: 5px 0 20px 0;
  text-align: center;
  transition: all 0.2s ease;
}
form .textarea{
  height: 100px;
  width: 100%;
  overflow: hidden;

}
form .textarea textarea{
  height: 130px;
  position: absolute;
  width: 588px;
  top:230px;
  outline:#777;
  color: gray;
  border: 1px solid gray;
  background: #fff;
  padding: 10px;
  font-size: 16px;
  resize: none;
  text-align: center;
  justify-content: center;
}
.textarea textarea:focus{
  border-color: #000;
}
form .btn{
  position: absolute;
  height: 30px;
  width: 590px;
  top:380px;
  left: 23px;

}
form .btn button{
  height: 100%;
  width: 100%;
  border: 0px solid #000;
  outline: none;
  background: #c5e8b4;
  color: #000 ;
  font-size: 17px ;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
}
form .btn button:hover{
  background: #c5e8b4;
}
<div class="Cont">
  <form action="" method="post">
    <div class="cont">
      <div class="post">
        <div class="text">Success </div>
        <div class="edit">edit</div>
      </div>

      <div class="star-widget">
        <div>
          <input type="radio" name="Rate" id="rate-5" value="5">
          <label for="rate-5" class="fas fa-star" value="rate-5"></label>
        </div>
        <div>

          <input type="radio" name="Rate" id="rate-4" value="4">
          <label for="rate-4" class="fas fa-star" value="rate-4"></label>
        </div>
        <div>
          <input type="radio" name="Rate" id="rate-3" value="3">
          <label for="rate-3" class="fas fa-star" value="rate-3"></label>
        </div>
        <div>
          <input type="radio" name="Rate" id="rate-2" value="2">
          <label for="rate-2" class="fas fa-star" value="rate-2"></label>
        </div>
        <div>
          <input type="radio" name="Rate" id="rate-1" value="1">
          <label for="rate-1" class="fas fa-star" value="rate-1"></label>
        </div>
      </div>


    </div>
    <div dir="ltr" class="textarea">
      <textarea name="Comment" cols="30" placeholder="Describe your experince in the website"></textarea>
    </div>
    <div class="btn">
      <button type="submit" name="submit">Send</button>
    </div>


  </form>

</div>

© www.soinside.com 2019 - 2024. All rights reserved.