[22/03/05] 리뷰 별점 기능 구현하기

Que Lin·2022년 3월 5일
1

html

<link href="/assets/css/star.css" rel="stylesheet"/>

 	<form class="mb-3" name="myform" id="myform" method="post">
	<fieldset>
		<span class="text-bold">별점을 선택해주세요</span>
		<input type="radio" name="reviewStar" value="5" id="rate1"><label
			for="rate1"></label>
		<input type="radio" name="reviewStar" value="4" id="rate2"><label
			for="rate2"></label>
		<input type="radio" name="reviewStar" value="3" id="rate3"><label
			for="rate3"></label>
		<input type="radio" name="reviewStar" value="2" id="rate4"><label
			for="rate4"></label>
		<input type="radio" name="reviewStar" value="1" id="rate5"><label
			for="rate5"></label>
	</fieldset>
	<div>
		<textarea class="col-auto form-control" type="text" id="reviewContents"
				  placeholder="좋은 수강평을 남겨주시면 Cocolo에 큰 힘이 됩니다! 포인트 5000p도 지급!!"></textarea>
	</div>
</form>								

star.css

#myform fieldset{
    display: inline-block;
    direction: rtl;
    border:0;
}
#myform fieldset legend{
    text-align: right;
}
#myform input[type=radio]{
    display: none;
}
#myform label{
    font-size: 3em;
    color: transparent;
    text-shadow: 0 0 0 #f0f0f0;
}
#myform label:hover{
    text-shadow: 0 0 0 rgba(250, 208, 0, 0.99);
}
#myform label:hover ~ label{
    text-shadow: 0 0 0 rgba(250, 208, 0, 0.99);
}
#myform input[type=radio]:checked ~ label{
    text-shadow: 0 0 0 rgba(250, 208, 0, 0.99);
}
#reviewContents {
    width: 100%;
    height: 150px;
    padding: 10px;
    box-sizing: border-box;
    border: solid 1.5px #D3D3D3;
    border-radius: 5px;
    font-size: 16px;
    resize: none;
}

예쁜 별 완성!

profile
1일 1커밋 1일 1벨로그!

0개의 댓글