강의

멘토링

커뮤니티

Inflearn Community Q&A

chohyein945057's profile image
chohyein945057

asked

HTML+CSS+JS Portfolio Practical Publishing (Season 1)

Practical publishing using pseudo-classes to style input fields (Input field using Font Awesome)

item부모요소, 자식요소

Written on

·

220

1

안녕하세요!
부모요소, 자식요소 관련 질문드립니다.ㅠㅠ

item 이 부모요소, fa가 자식요소인건 이해했습니다.
그런데 왜 item 밑의 input에는 position: absolute; 를 주지 않아도, 너비값이 상속이 가능한지가 궁금합니다.

정리하자면
왜 fa에는 absolute 값을 주고, input에는 주지 않는지! 가 궁급합니다.

 

.item {
    /* border: 1px solid red; */
    width: 300px;
    position: relative;
}
.item input {
    border: 1px solid lightgray;
    height: 40px;
    width: inherit;
    border-radius: 5px;
    padding: 10px;
    box-sizing: border-box;
    padding-left: 40px;
    outline: none;
    transition: 0.3s;
}

.item .fa {
    position: absolute;
    top: 0;
    left: 0;
    color: gray;
    font-size: 20px;
    width: 40px;
    height: 40px;
    /* border: 1px solid blue; */
    text-align: center;
    line-height: 40px;

}
HTML/CSSjquery

Answer 1

0

codingworks님의 프로필 이미지
codingworks
Instructor

일단 부모요소의 속성을 상속 받는 것은 몇가지 없습니다.
예를들어 text-align, font-size, color 이런 것 들입니다.
너비 높이 이런건 부모요소의 속성을 상속 받지 않습니다.
상속받으려면 inherit를 사용해야 합니다.
부모요소의 속성 상속과 absolute는 관계 없습니다.

chohyein945057's profile image
chohyein945057

asked

Ask a question