• 카테고리

    질문 & 답변
  • 세부 분야

    웹 개발

  • 해결 여부

    미해결

position 속성으로 인한 높이값문의

22.03.29 16:19 작성 조회수 2.85k

1

div 안에 div가 존재하고 자식 div에 position:absolute를 주면
높이값을 잃기 때문에 높이값을 부모요소에 준다고 알고있습니다.
 
근데 그 높이값이 고정으로 주는게 아니라 안에 자식들이 div가 여러개 있거나 자식 div높이값에 따라서 유동적으로 부모 div값도 고정값이 아닌 자동으로 높이값이 변경되게 하려면 어떻게 해야하나요?
꼭 고정값으로 줘야 하나요? 당연히...자식에 의해서 부모의 높이값을 주면 담길꺼라 생각했는데 실제 담기는게 아니라...부모 사이즈만 늘어나는것 같습니다.
 

답변 5

·

답변을 작성해보세요.

0

James Wesley님의 프로필

James Wesley

2023.10.23

Great blog post! I found the information really helpful and well-written. Thanks for sharing this valuable content. As providers of Nationwide truck repair, we appreciate the insights you've shared here. Looking forward to reading more from you in the future. Keep up the good work! 😊👍

0

Chris Nolan님의 프로필

Chris Nolan

2023.08.17

As shown in the figure below, if a child element has absolute, it floats in the air like a float and is attached by coordinates, so the parent element thinks that there is no child element, so the height value disappears. This is because the height value of the parent element is height: auto. truck repair shops

0

margotcantrell19님의 프로필

margotcantrell19

2022.12.22

position 속성은 웹 문서 안 요소들을 어떻게 배치할 지를 정하는 속성입니다 pacman 30th anniversary. position 속성을 이용하면 텍스트나 이미지를 원하는 위치로 배치할 수 있고 어떤 방식으로 놓을 지를 결정할 수 있죠. 

0

Bevis Jason님의 프로필

Bevis Jason

2022.12.21

If you are looking to find out the height coreball value of a particular property, you can use the position property to do so. This property returns the height of a given object at a given position.

0

아래 그림처럼 자식요소가 absolute를 가지면 float 처럼 공중에 떠서 좌표로 붙는 것이기 때문에 부모요소가 자식요소가 없다고 생각해서 높이 값이 없어집니다. 부모요소의 높이 값은 height: auto인 상태라서 그렇습니다.
그래서 부모요소에 높이 값을 지정해서 주어야 합니다.

말씀하신 것 처럼 자식요소가 bsolute를 가지면서 부모요소가 높이 값을 자식요소 만큼 자동으로 가질 수 있는 방법은 제가 알기로는 없습니다.

samwilliam166님의 프로필

samwilliam166

2023.10.11

The position property is a fundamental CSS property that controls the positioning of an element within its containing element. It can take various values, including:

  1. static: This is the default value, and the element is positioned according to the normal flow of the document. The height property determines the element's height, and it's not affected by position: static.

  2. relative: When you set an element's position to relative, you can use the top, right, bottom, and left properties to shift the element from its normal position. However, the space it occupies in the layout is not altered. The height property still determines the element's height.

  3. absolute: Elements with position: absolute are positioned relative to the nearest positioned (non-static) ancestor. They are removed from the normal document flow, and their height doesn't affect the layout of other elements. The height property can still be used to set their height.

  4. fixed: Elements with position: fixed are positioned relative to the viewport (the browser window). They do not affect the layout of other elements, and the height property can be used to set their height.

  5. sticky: Elements with position: sticky behave as if they were relatively positioned until they reach a specified scroll position, at which point they become fixed. The height property determines their height when they are in the normal flow and are not fixed or relative to the viewport.

So, the position property affects the positioning of an element within the layout, but the height property continues to determine the element's height regardless of the position value. However, for elements with position: absolute, position: fixed, or position: sticky, their positioning can potentially overlap or affect the positioning of other elements on the page. 24 hours trailer repair shop