테스트 사이트 - 개발 중인 베타 버전입니다

css 탭 메뉴 소스 질문입니다. 채택완료

주사쟝 7년 전 조회 2,578

</p>

<p><div id="css_tabs">

    <input id="tab1" type="radio" name="tab" checked="checked" />

    <input id="tab2" type="radio" name="tab" />

    <input id="tab3" type="radio" name="tab" />

    <p><label for="tab1">ENG</label></p>

    <p><label for="tab2">CHN</label></p>

    <p><label for="tab3">KOR</label></p>

    <div class="tab1_content"></div>

    <div class="tab2_content"></div>

    <div class="tab3_content"></div>

</div></p>

<p>

 

</p>

<p> #css_tabs{text-align:center;}

 /* 탭 선택 시 표시할 요소(div) 정의(1번 탭 선택 시 첫 번째 div 요소 표시) */

 #css_tabs input:nth-of-type(1), #css_tabs input:nth-of-type(1) ~ div:nth-of-type(1), #css_tabs input:nth-of-type(2), #css_tabs input:nth-of-type(2) ~ div:nth-of-type(2), #css_tabs input:nth-of-type(3), #css_tabs input:nth-of-type(3) ~ div:nth-of-type(3) {

  display:none

 }

 #css_tabs input:nth-of-type(1):checked ~ div:nth-of-type(1), #css_tabs input:nth-of-type(2):checked ~ div:nth-of-type(2), #css_tabs input:nth-of-type(3):checked ~ div:nth-of-type(3) {

  display:block

 }</p>

<p> #css_tabs p{display:inline-block;}

 

 

 /* 라벨 기본 스타일 지정 */

 #css_tabs label {

 text-align:center;

  padding:5px;

  text-align:center;

  width:20%;

  line-height:1.8em;

  font-weight:700;

  background:#eee;

  color:#777;

  border:1px solid #ccc;

 }

 #css_tabs label:hover {

  cursor:pointer

 }

 /* 선택된 라벨, 커서를 올린 라벨 스타일 지정 */

 #css_tabs input:nth-of-type(1):checked ~ label:nth-of-type(1), #css_tabs p > label[for=tab1]:hover {

  background:#1428a0;

  color:#fff

 }

 #css_tabs input:nth-of-type(2):checked ~ label:nth-of-type(2), #css_tabs p > label[for=tab2]:hover {

  background:#1428a0;

  color:#fff

 }

 #css_tabs input:nth-of-type(3):checked ~ label:nth-of-type(3), #css_tabs p > label[for=tab3]:hover {

  background:#1428a0;

  color:#fff

 }

 /* 실제 내용이 담긴 div 요소 스타일 지정 */

 #css_tabs .tab1_content, #css_tabs .tab2_content, #css_tabs .tab3_content {

  padding:2em;

  width:100%;

  height:100%;

  box-sizing:border-box;

  }

 #css_tabs iframe{margin:0 auto;}</p>

<p>

 

위으 코드처럼 css 탭메뉴를 구현했는데요.

css에서 선택된라벨에 배경색이 안먹습니다.

어떤걸 수정해야 할까요?

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트
bonobono
7년 전

html을

 

                           
1
   
2
   
3

 

이렇게..

로그인 후 평가할 수 있습니다

답변에 대한 댓글 2개

주사쟝
7년 전
네 원래 label에 바로 inline-block 주면 되는거였는데,
워드프레스에서 inline-block 이 계속 안먹더라구요 ㅠ
그래서 p로 묶어서 가로배열을 해줬는데..ㅠ
p태그로 묶은 상태에서 css를 수정하는 방법은 없을까여?
주사쟝
7년 전
아 해결했습니다.
워드프레스 text 구간에서 구간을 넘겨서 했더니..그게 <br>로 인식해서 그랬네요.
답변 감사합니다. ^^

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인