박스 가운데 맞추는 문제 질문드려요.
소1유물
전체적으로 화면 가운데를 맞춰야 하고.box03 이라는 박스하나로 4개 또는 6개가 한줄에 2개씩 나와야 합니다.문제는 .box03에 박스간 간격때문에margin-right를 주다보니 아래 그림에서 파란색 부분에도 마진이 들어가게 되서#box3 가 전체적으로 100px 늘어나고 그에 따라 #box1, #box4와 가운데가 맞지 않고 틀어지게 됩니다.오렌지색 라인부분으로 맞춰져야 하거든요...box03에 들어갈 내용이 랜덤이라 css로 짝수번째에만 margin-right를 빼거나 할수도 없다고 하네요.#box3에 margin이나 padding을 줬더니 화면 해상도에 따라 가운데로 가지 않거나 하구요.해결방법이 없을까요?정리를 해보면 #box1 , #box3 의 가로길이가 다른것을900,1000의 가로크기값을 가진 박스를 왼쪽 위치를 맞추면서 해상도와 관계없이 화면 가운데로 가게 하라는건데...==================================================================================================================!DOCTYPE html
html lang=ko
head
title박스문제/title
meta charset=euc-kr /
meta http-equiv=X-UA-Compatible content=IE=edge
style
#wrap {width:100%; height:50px;}
#box1 {width:900px; margin:0 auto; height:100px; background:#bbb; margin-bottom:20px; }
#box2 {width:100%; height:100px; background:#bbb; margin-bottom:20px; }
#box3 {width:1000px; height:440px; margin:0 auto; background:#aaa; margin-bottom:20px;}
.box03{float:left; width:400px; height:200px; margin-right:100px; margin-bottom:20px; background:#666;}
#box4 {width:900px; margin:0 auto; height:100px; background:#bbb;}
/style
/headbody
div id=wrap
div id=box1/div
div id=box2/div
div id=box3
div class=box03/div
div class=box03/div
div class=box03/div
div class=box03/div
/div
div id=box4/div
/div
/body
/html==================================================================================================================덧글 감사합니다.덧글들 보다가 어찌하다가 이렇게 해보니 되긴하네요.
소스수정 추가해봅니다.
이렇게 하니 어찌되었건 가운데가 되긴하는데...맞는지는 모르겠어요.#big01에 포지션으로 가운데 맞추고 다시 왼쪽마진을 줬는데..============================================================================================================!DOCTYPE html
html lang=ko
head
title박스문제 01/title
meta charset=euc-kr /
meta http-equiv=X-UA-Compatible content=IE=edge
style
#wrap {width:100%; height:50px;}
#box1 {width:900px; margin:0 auto; height:100px; background:#bbb; margin-bottom:20px; }
#box2 {width:100%; height:100px; background:#bbb; margin-bottom:20px; }
#big {width:100%; position:relative;}
#big01 {width:900px; position:absolute; left:50%; background:red; margin-left:-450px;}
#box3 {width:1000px; }
.box03{float:left; width:400px; height:200px; margin-right:100px; margin-bottom:20px; background:#666;}
#box4 {width:900px; margin:0 auto; height:100px; background:#bbb;}
/style
/head
body
div id=wrap
div id=box1/div
div id=box2/div
div id=big
div id=big01
div id=box3
div class=box03/div
div class=box03/div
div class=box03/div
div class=box03/div
/div
/div
/div
div id=box4/div
/div
/body
/html
-
덕이
#box3을 width:1100px로 해주고 .box3을 양옆에 50씩 마진주면 안되나염?
-
물티슈
뒤로걷기님이 말씀하신데로 반복문으로 짝수일때 class추가해서 margin-right:0; 처리하는게 제일 적합한 방법이라고 생각해요
이거라면 box03이 아무리 랜덤으로 뿌려진다해도 짝수라는 위치는 변함이 없으니까요! -
머즌일
프로그래머 영역일거 같긴한데...
안되서 .box03에 좌우 마진값을 줬더니 좀 보기 싫어서 속상하네요.
가운데 간격이 그만큼 줄어서 .box03 끼리 여백이 줄다보니 가독성도 떨어지고.. -
라임나무
프로그래머가 이해를 못한거 아닐까요? 시도는 해봤데요?;;; 왜 안되지 왜안될까요 ㅠㅠㅠ
-
헤벌심
저도 이야기했는데 안된다는 답만 들어서...
-
설아
box03에 들어갈 내용이 랜덤이라고 box03까지 랜덤이 될필요는 없지 않나요?
랜덤으로 뿌릴 범위에 box03 안쪽만 들어가면 안되는거에요?
음 그리고 box03내용이 바뀐다고 해도 짝수위치는 안변하는거 아닌가요?
헷갈린당 @..@ -
얀새
#box3 에 overflow:hidden을주고
#box3 width값을 1000px을 주면 결과는 똑같구요.
900px을 주면 .box03들이 아래로 떨어지게 되는 결과가... -
딥블루
그럼 #box3에만 overflow:hidden값을 줘보세요. 그럼 원하시는 틀안에서 내용이 출력될꺼같은데요.
-
세나
저는 그냥 귀찮은 프로그래머의 핑계로 들리는걸까요.. box번호%2했을때 0값이나오는 박스에 클래스를 추가해주면되는데.. 백앤드영역 모르는 저도 알만한 간단한부분인데요.. 개발자가 못하겟다고하면 그냥 위 방식으로 스크립트 처리해버리셔도 됩니다
-
미리내
#box3에 overflow:hidden을 주시고 .mr100 이런식으로 마진값넣는 클래스를 하나 더 추가해서 왼쪽 div에만 심으셔도 되지 않을까요? 방법은 여러가지일듯요~