발전하는 나를 기록하기 위해

일요일 스터디 / css실습 position fixed, margin 본문

개발

일요일 스터디 / css실습 position fixed, margin

발폼도래 2022. 1. 9. 16:40
728x90

상단바, 그 밑에 바 하나 더 position : fixed로 설정하고 a 태그 집어 넣었는데

위치 설정이 내가 생각한대로 안됨.

 

a 태그에서 margin-top 설정했는데 두번 째 바와 같이 margin 설정이 들어갔다.

fixed 설정 주면 처음 지정한 위치 고정일텐데 왜...?

 

그래서 a 태그를 div로 감싸주고  진행했다.

 

<div id="friends-display">
<  a id="friends-display__link">
  <i class="fas fa-info-circle fa-sm"></i>
  Friends' Names Display
  <i class="fas fa-chevron-right fa-xs"></i>
  </a>
</div>

 

 

#friends-display {
display: flex;
justify-content: center;
top: 90px;
width: 100%;
position: fixed;
background-color: #fafafa;
padding: 15px 0px;
}
#friends-display__link {
padding: 20px, 0px;
font-size: 16px;
}

감싼 div태그에서 위치 고정시켜주고 

flex와 justify-content : center; 설정주었는데 가운데로 안왔다.

뭘 놓쳤나 고민해보니 width 안줬다.

width : 100% 설정....

 

이것 때문에 1시간이나 날렸다.