메뉴 건너뛰기

프로그램언어

조회 수 4856 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

[방법 1]

 

To center a table, you need to set the margins, like this:

  table.center {margin-left:auto; margin-right:auto;}

And then do this:

  <table class="center">
    ...
  </table>

At this point, Mozilla and Opera will center your table. Internet Explorer 5.5 and up, however,

needs you to add this to your CSS as well:

  body {text-align:center;}
 
[방법2]

If you want your table to be a certain percentage width, you can do this:

  table#table1 {width:70%; margin-left:15%; margin-right:15%;}

And then in your HTML/XHTML, you would do this:

  <table id="table1">
    ...
  </table>

 

Note that I was using an id to describe the table. You can only use an id once on a page. If you had many tables on a page that you wanted to be the same width and centered, you would do this in your CSS:

  table.center {width:70%; margin-left:15%; margin-right:15%;}

And this in your HTML:

  <table class="center">
    ...
  </table>
  <table class="center">
    ...
  </table>
[방법3]
 

If you want your table to be of fixed width, define your CSS like this:

div.container {width:98%; margin:1%;}
table#table1 {text-align:center; margin-left:auto; margin-right:auto; width:100px;}
tr,td {text-align:left;}

Set "width:100px" to whatever width you need.

"text-align: center" is there for Internet Explorer, which won't work without it. Unfortunately, "text-align: center" will center all the text inside your table cells, but we counter that by setting "tr" and "td" to align left.

In your HTML, you would then do this:

  <div class="container">
    <table id="table1">
      ...
    </table>
  </div>

  1. <iframe>으로 올린 유투브 동영상 z-index 문제

    Date2015.02.03 Views6644
    Read More
  2. background-size 속성

    Date2016.12.23 Views5874
    Read More
  3. Box CSS

    Date2014.02.27 Views6468
    Read More
  4. CSS - display : flex를 통한 수직, 수평 정렬하기

    Date2021.03.09 Views428
    Read More
  5. CSS - position:absolute 가운데, 중앙 정렬하기

    Date2021.03.09 Views371
    Read More
  6. CSS / 링크 상태 속성 / <a>태그 CSS / 밑줄 없애기,변경하기

    Date2023.01.27 Views92
    Read More
  7. CSS : 반응형 웹(Responsive Web)

    Date2017.04.14 Views5938
    Read More
  8. CSS background-repeat 이해하기

    Date2016.12.22 Views4738
    Read More
  9. CSS 미적용, 다르게 적용

    Date2021.03.26 Views196
    Read More
  10. CSS/table/border-collapse/테이블 선 속성

    Date2023.01.27 Views66
    Read More
  11. CSS/기호/공백/띄어쓰기/<>

    Date2023.01.27 Views82
    Read More
  12. CSS3를 이용하여 둥근모서리 박스 만들기

    Date2016.12.22 Views5840
    Read More
  13. css를 이용한 테이블 가운데 정렬

    Date2016.12.22 Views4856
    Read More
  14. IIS7 에서 woff MIME 등록하기.

    Date2015.02.03 Views4726
    Read More
  15. input box 테두리 없애기

    Date2016.12.23 Views9667
    Read More
  16. light박스 css로 흉내내기

    Date2016.12.22 Views4618
    Read More
  17. 기본적으로 보이는 스크롤바를 없애기

    Date2016.12.23 Views5118
    Read More
  18. 네이버 나눔글꼴 적용

    Date2014.03.01 Views6666
    Read More
  19. 둥근 모서리 박스 css

    Date2014.02.27 Views5854
    Read More
  20. 링크 오버속성+버튼 디자인

    Date2016.12.23 Views4664
    Read More
Board Pagination Prev 1 2 Next
/ 2

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved