[TIL] 231119

이세령·2023년 11월 19일
0

TIL

목록 보기
118/118

가로 스크롤 구현

<S.EmotionButtonBox>
          <S.EmotionButtonWrapper>
            {hashtags.map((item, idx) => {
              return <S.EmotionButton>{item}</S.EmotionButton>;
            })}
          </S.EmotionButtonWrapper>
        </S.EmotionButtonBox>

style

export const EmotionButtonBox = styled.div`
  display: 'block';
  padding-bottom: 5px;
  overflow-x: scroll;
`;

export const EmotionButtonWrapper = styled.div`
  display: inline-block;
  line-height: 29px;
  width: 480px;
  padding: 0px 20px;
  gap: 8px;
`;

export const EmotionButton = styled.span`
  padding: 5px 10px;
  text-align: center;
  border-radius: 14px;
  border: 1px solid #292828;
  margin: 5px 5px;

  color: #292828;
  font-size: 12px;
  font-weight: 700;
  line-height: 16px; /* 133.333% */
  letter-spacing: 0.12px;

  &:hover {
    border: 1px solid #bd2024;
    background-color: ${(props) => props.theme.redNormalColor};
    color: white;
  }
`;

가장 상위에 overflow-x: scroll을 설정해주고 inline-block으로 글자들이 세로로 나열되지 않도록 방지해줬다.

profile
https://github.com/Hediar?tab=repositories

0개의 댓글