css 탭 메뉴 소스 질문입니다.

css 탭 메뉴 소스 질문입니다.

QA

css 탭 메뉴 소스 질문입니다.

본문


<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>

 


 #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
 }
 #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;}

 

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

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

어떤걸 수정해야 할까요?

이 질문에 댓글 쓰기 :

답변 1

html을

 

<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" />
    <label for="tab1">ENG</label>
    <label for="tab2">CHN</label>
    <label for="tab3">KOR</label>
    <div class="tab1_content">1</div>
    <div class="tab2_content">2</div>
    <div class="tab3_content">3</div>
</div>

 

이렇게..

네 원래 label에 바로 inline-block 주면 되는거였는데,
워드프레스에서 inline-block 이 계속 안먹더라구요 ㅠ
그래서 p로 묶어서 가로배열을 해줬는데..ㅠ
p태그로 묶은 상태에서 css를 수정하는 방법은 없을까여?

답변을 작성하시기 전에 로그인 해주세요.
전체 88
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT