position fixed일 때 가운데 정렬
2022. 5. 19. 21:52ㆍFrontend/HTML & CSS
기본적으로 가운데 정렬은 margin 속성을 0 auto 로 적용하면 된다. 그러나 position이 fixed일 때는 위 속성만으로는 적용되지 않는다. 추가적으로 left, right 값을 0으로 설정해줘야함.
적용 예제
@media screen and (max-width: 545px) {
.sidebar {
position: fixed;
width: 100px;
margin: 0 auto;
left: 0;
right: 0;
bottom: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
}

참고자료 : https://saeatechnote.tistory.com/20
position: fixed; 가운데 정렬하기
position:fixed;가 적용된container에 가운데 정렬하는법. .class-name { position: fixed; margin: 0 auto; left: 0; right: 0; }
saeatechnote.tistory.com
'Frontend > HTML & CSS' 카테고리의 다른 글
| <video> 태그 autoplay 하기 : muted 속성 넣기 (0) | 2023.04.24 |
|---|---|
| 2022/06/01 CSS 신기능 (0) | 2022.06.01 |
| 안티앨리어싱 (0) | 2022.05.26 |
| gmail에서 적용되지 않는 태그, css속성 (0) | 2022.05.23 |
| 구글 아이콘 (1) | 2022.05.21 |