[CSS] div 고정폭 + 가변폭 > 기술자료 | 해피정닷컴

[CSS] div 고정폭 + 가변폭 > 기술자료

본문 바로가기

사이트 내 전체검색

[CSS] div 고정폭 + 가변폭 > 기술자료

HTML [CSS] div 고정폭 + 가변폭

페이지 정보


본문

왼쪽은 130px로 고정
오른쪽은 그 나머지를 지정하고자 하고자 할때

CSS3의  calc() 함수를 이용하면 해결이 가능합니다.

calc() 함수 사용시 유의사항
-. 모든 계산은 왼쪽에서 오른쪽으로 진행
-. 사칙연산과 마찬가지로 곱하기, 나누기 먼저 계산
-. 호환성을 위해 -moz, -webkit과 같은 vendor-prefix를 먼저 작성
-. calc(100% - 10px)과 같이 더하기(+). 빼기(-) 연산자의 경우 앞뒤 공백
-. 곱하기(x), 나누기(/)는 공백 불필요

지원브라우저
IE 9+ , Firefox 4+(모바일 19+), Chrome 19+(모바일 25+), Safari 6+(모바일 6+), Blackberry 10+


<style>
#left_child {
    width:130px; 
    float:left; 
    height:80px; 
}
#right_child {
    float:left;
    height:80px;
    width:-webkit-calc(100% - 130px);
    width:-moz-calc(100% - 130px);
    width:calc(100% - 130px);  
}

#child_100percent {
    float:left;
    height:40px;
    width:-webkit-calc(100%/2);
    width:-moz-calc(100%/2);
    width:calc(100%/2);  
    text-align:center;
    font-size:13px;
}
#child_100percent a {color:#707070; }
#child_100percent a:hover {color:#ef2a20;}
#child_100percent a.on {font-weight:bold; color:#ef2a20;}

#child_50percent {
    float:left;
    height:40px;
    width:-webkit-calc(100%/2);
    width:-moz-calc(100%/2);
    width:calc(100%/2);  
    text-align:center;
    font-size:13px;
}
#child_50percent a {color:#707070; }
#child_50percent a:hover {color:#ef2a20;}
#child_50percent a.on {font-weight:bold; color:#ef2a20;}

#child_33percent {
    float:left;
    height:40px;
    width:-webkit-calc(100%/3);
    width:-moz-calc(100%/3);
    width:calc(100%/3);  
    text-align:center;
    font-size:13px;
}
#child_33percent a {color:#707070; }
#child_33percent a:hover {color:#ef2a20;}
#child_33percent a.on {font-weight:bold; color:#ef2a20;}

#child_25percent {
    float:left;
    height:40px;
    width:-webkit-calc(100%/4);
    width:-moz-calc(100%/4);
    width:calc(100%/4);  
    text-align:center;
    font-size:13px;
}
#child_25percent a {color:#707070;}
#child_25percent a:hover {color:#ef2a20;}
#child_25percent a.on {font-weight:bold; color:#ef2a20;}

#child_20percent {
    float:left;
    height:40px;
    width:-webkit-calc(100%/5);
    width:-moz-calc(100%/5);
    width:calc(100%/5);  
    text-align:center;
    font-size:13px;
}
#child_20percent a {color:#707070;}
#child_20percent a:hover {color:#ef2a20;}
#child_20percent a.on {font-weight:bold; color:#ef2a20;}
</style>

<div>
    <div id="left_child">왼쪽</div>
    <div id="right_child">오른쪽</div>
</div>




참고자료
http://fils.tistory.com/774
http://techbug.tistory.com/215 

댓글목록

등록된 댓글이 없습니다.


Total 2,643건 41 페이지
  • RSS
기술자료 목록
1843
ClassicASP   12913  2016-10-28 17:19 ~ 2018-08-24 16:00  
1842
WordPress   10550  2016-10-22 01:37  
1841
JavaScript   11734  2016-10-18 13:52 ~ 2021-02-19 08:23  
1840
JavaScript   12188  2016-10-11 22:39  
1839
WordPress   10531  2016-10-10 16:28  
1838
영카트   11707  2016-10-10 12:48 ~ 2019-04-14 23:00  
1837
PHP   35459  2016-10-06 22:14 ~ 2018-03-30 14:01  
1836
HTML   14089  2016-10-06 11:49  
1835
제로보드   15043  2016-09-30 16:32 ~ 2022-04-15 19:45  
1834
WordPress   17320  2016-09-30 00:40  
1833
WordPress   9568  2016-09-30 00:28 ~ 2020-08-28 12:11  
1832
호스팅   20665  2016-09-26 23:00 ~ 2017-06-05 00:00  
1831
JavaScript   15093  2016-09-22 08:49 ~ 2021-10-19 18:54  
1830
JavaScript   15539  2016-09-19 19:47  
1829
JavaScript   28282  2016-09-19 18:52  
1828
그누보드   16545  2016-09-12 16:29 ~ 2021-02-26 16:55  
1827
Editor   9945  2016-09-10 11:11  
1826
JavaScript   13531  2016-09-09 02:51  
열람
HTML   14324  2016-09-09 00:58 ~ 2016-09-20 00:00  
1824
JavaScript   17937  2016-09-08 00:17  

검색

해피정닷컴 정보

회사소개 회사연혁 협력사 오시는길 서비스 이용약관 개인정보 처리방침

회사명: 해피정닷컴   대표: 정창용   전화: 070-7600-3500   팩스: 042-670-8272
주소: (34368) 대전시 대덕구 대화로 160 대전산업용재유통단지 1동 222호
개인정보보호책임자: 정창용   사업자번호: 119-05-36414
통신판매업신고: 제2024-대전대덕-0405호 [사업자등록확인]  
Copyright 2001~2025 해피정닷컴. All Rights Reserved.