skip to Main Content

I’m facing problem in creating a rating interface that will asks the user to rate the website(by clicking the stars) and add a comment.
The stars became in vertical instead in horizontal, as shown in the link’s picture, I tried many tings but I won’t works.

 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>

2

Answers


  1. /* 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>

    Try this code.

    Login or Signup to reply.
  2. You can wrap each label and input in a div and convert the star-widget into flex. Something like below

    /* 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>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search