커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
가운데 정렬이 안 됩니다..!
[왕초보] 웹개발 종합반 v0
2주차
북마크
김*진
댓글
8
추천
0
조회수
24
조회수
24
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


2주차 스파르타 플릭스 만들기에서 mypostingbox에 있는 '기록하기' button을 width 50%로 설정하여 가운데로 위치 시켜보고자 합니다.

따라서 style에서

.mypostingbox > button {

width: 50%;

display: flex;

flex-direction: column;

align-items: center;

justify-content: center;

}

로 가운데 정렬을 진행하고자 하였는데, width 값은 변하였지만 가운데 정렬은 하지 않았습니다.

(mypostingbox 내에 버튼은 '기록하기' 버튼 하나뿐이라 이렇게 진행해도 괜찮을 것이라고 생각했습니다.. )


또한 따로 <div class="mybtn">과 같이 구역을 지정하여 다음과 같이 진행하였습니다.

.mybtn {

width: 50%;


display: flex;

flex-direction: row;

align-items: center;

justify-content: center;

}


이렇게 진행을 하였을 때도, 기록하기 버튼이 postingbox의 중앙에 위치하지 않았습니다.


왜 정중앙 배치가 되지 않고 있는 것인지 이유가 궁금합니다!

혹 위에서 설정한 margin과 padding 값 때문인가요? 이 두 값은 '기록하기' 버튼과는 상관이 없다고 생각하였습니다.


스파르타 즉문즉답




작성한 코드 및 에러 메세지

<!DOCTYPE html>

<html lang="en">


<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"

integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

<style>

@import url('https://fonts.googleapis.com/css2?family=Gasoek+One&family=Hahmlet:wght@300&family=Nanum+Myeongjo:wght@400;700&display=swap');


* {

font-family: 'Gasoek One', sans-serif;

font-family: 'Hahmlet', serif;

font-family: 'Nanum Myeongjo', serif;

}


body {

background-color: black;

}


.mymain {

background-color: green;

background-image: url('https://occ-0-1123-1217.1.nflxso.net/dnm/api/v6/6AYY37jfdO6hpXcMjf9Yu5cnmO0/AAAABeIfo7VL_VDyKnljV66IkR-4XLb6xpZqhpLSo3JUtbivnEW4s60PD27muH1mdaANM_8rGpgbm6L2oDgA_iELHZLZ2IQjG5lvp5d2.jpg?r=e6e.jpg');

background-position: center;

background-size: cover;


color: white;


}


.mycards {

width: 1200px;


margin: 50px auto 30px auto;

}


.mypostingbox {


width: 500px;


border: 1px solid white;

border-radius: 5px;

padding: 20px;


margin: 30px auto 0px auto;

}


.form-floating>input {

background-color: transparent;

color: white;

}


.form-floating>label {

background-color: transparent;

color: white;

}


.input-group-text {

background-color: transparent;

color: white;

}


.mybtn {

width: 50%;


display: flex;

flex-direction: row;

align-items: center;

justify-content: center;

}

</style>

</head>


<body>

<header class="p-3 text-bg-dark">

<div class="container">

<div class="d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start">

<a href="/" class="d-flex align-items-center mb-2 mb-lg-0 text-white text-decoration-none">

<svg class="bi me-2" width="40" height="32" role="img" aria-label="Bootstrap">

<use xlink:href="#bootstrap"></use>

</svg>

</a>


<ul class="nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0">

<li><a href="#" class="nav-link px-2 text-danger">spartaflix</a></li>

<li><a href="#" class="nav-link px-2 text-white"></a></li>

<li><a href="#" class="nav-link px-2 text-white">시리즈</a></li>

<li><a href="#" class="nav-link px-2 text-white">영화</a></li>

<li><a href="#" class="nav-link px-2 text-white">내가 찜한 콘텐츠</a></li>

</ul>


<form class="col-12 col-lg-auto mb-3 mb-lg-0 me-lg-3" role="search">

<input type="search" class="form-control form-control-dark text-bg-dark" placeholder="Search..."

aria-label="Search">

</form>


<div class="text-end">

<button type="button" class="btn btn-outline-light me-2">Login</button>

<button type="button" class="btn btn-danger">Sign-up</button>

</div>

</div>

</div>

</header>

<div class="mymain">

<div class="p-5 mb-4 bg-body-tertiary rounded-3">

<div class="container-fluid py-5">

<h1 class="display-5 fw-bold">킹덤</h1>

<p class="col-md-8 fs-4">병든 왕을 둘러싸고 흉흉한 소문이 떠돈다. 어둠에 뒤덮인 조선, 기이한 역병에 신음하는 산하. 정체 모를 악에 맞서 백성을 구원할 희망은 오직

세자뿐이다.</p>

<button type="button" class="btn btn-outline-light">영화 기록하기</button>

<button type="button" class="btn btn-outline-light">상세 정보</button>

</div>

</div>

</div>

<div class="mypostingbox">

<div class="form-floating mb-3">

<input type="email" class="form-control" id="floatingInput" placeholder="영화 이미지 주소">

<label for="floatingInput">영화 이미지 주소</label>

</div>

<div class="form-floating mb-3">

<input type="email" class="form-control" id="floatingInput" placeholder="영화 제목">

<label for="floatingInput">영화 제목</label>

</div>

<div class="input-group mb-3">

<label class="input-group-text" for="inputGroupSelect01">별점</label>

<select class="form-select" id="inputGroupSelect01">

<option selected>별점 선택</option>

<option value="1">⭐️</option>

<option value="2">⭐️⭐️</option>

<option value="3">⭐️⭐️⭐️</option>

<option value="3">⭐️⭐️⭐️⭐️</option>

<option value="3">⭐️⭐️⭐️⭐️⭐️</option>

</select>

</div>

<div class="form-floating mb-3">

<input type="email" class="form-control" id="floatingInput" placeholder="추천 이유">

<label for="floatingInput">추천 이유</label>

</div>

<div class="mybtn">

<button type="button" class="btn btn-danger">기록하기</button>

</div>

</div>

<div class="mycards">

<div class="row row-cols-1 row-cols-md-4 g-4">

<div class="col">

<div class="card h-100">

<img src="https://movie-phinf.pstatic.net/20210728_221/1627440327667GyoYj_JPEG/movie_image.jpg"

class="card-img-top" alt="...">

<div class="card-body">

<h5 class="card-title">영화 제목</h5>

<p class="card-text">영화 코멘트</p>

</div>

</div>

</div>

<div class="col">

<div class="card h-100">

<img src="https://movie-phinf.pstatic.net/20210728_221/1627440327667GyoYj_JPEG/movie_image.jpg"

class="card-img-top" alt="...">

<div class="card-body">

<h5 class="card-title">영화 제목</h5>

<p class="card-text">영화 코멘트</p>

</div>

</div>

</div>

<div class="col">

<div class="card h-100">

<img src="https://movie-phinf.pstatic.net/20210728_221/1627440327667GyoYj_JPEG/movie_image.jpg"

class="card-img-top" alt="...">

<div class="card-body">

<h5 class="card-title">영화 제목</h5>

<p class="card-text">영화 코멘트</p>

</div>

</div>

</div>

<div class="col">

<div class="card h-100">

<img src="https://movie-phinf.pstatic.net/20210728_221/1627440327667GyoYj_JPEG/movie_image.jpg"

class="card-img-top" alt="...">

<div class="card-body">

<h5 class="card-title">영화 제목</h5>

<p class="card-text">영화 코멘트</p>

</div>

</div>

</div>

</div>

</div>

</body>


</html>오류 발생 시, 작성한 코드 전체와 에러 메시지를 첨부해 주세요.

Tip 1) </> 아이콘을 눌러 코드박스를 만들어 보세요.

Tip 2) Ctrl+A(맥의 경우 Command+A) 단축키로 코드를 한 번에 선택할 수 있어요!




취소
 공유
취소
댓글 0
댓글 알림
나의얼굴