커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
1-12 style.css로 스타일태그 분리했을 때
[GPT] 웹개발 종합반 v0
1주차
북마크
조*희
댓글
3
추천
0
조회수
14
조회수
14
답변 완료

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

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



<style> ~ </style> 부분을 style.css로 분리했을 때 배경사진 적용이 안됩니다. 나머지 스타일 요소들은 그대로 적용됩니다. 분리 전에도 잘 작동됐습니다.


스파르타 즉문즉답




작성한 코드 및 에러 메세지

<style>을 떼어낸 html :

<!DOCTYPE html>
<html lang="en">


<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
   
 <link rel="stylesheet" href="style.css">
</head>


<body>
    <nav class="navbar">
        <img class='logo' src="https://s3.ap-northeast-2.amazonaws.com/materials.spartacodingclub.kr/webjong/images/sparta-logo.svg"
            alt="" />
        <div class="weather">
            <img src="https://ssl.gstatic.com/onebox/weather/64/partly_cloudy.png" id="weather-icon">
            <p>날씨 맑음, 20ºC</p>
        </div>
    </nav>
    <!-- main -->
    <div class="container">
        <div class="greeting">
            <h1>Hello, My name!</h1>
            <h1>12:30</h1>
        </div>


        <div class="motto">
            <h3>My life's motto</h3>
            <h2>웃으면 행복해집니다.</h2>
        </div>


    </div>


    <!-- /* footer */ -->
    <div class="footer">
        <p>- 작자 미상 -</p>
        <p>멋진 명언입니다. 아이스크림을 먹으면 행복해져요.</p>
    </div>


</body>


</html>

<style>부분

<style>
body {
    background-image: url('https://s3.ap-northeast-2.amazonaws.com/materials.spartacodingclub.kr/webjong/images/background.jpg');
    background-position: :center;
    background-size: center;
    color: white;
}


.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}


.weather {
    display: flex;
    align-items: center;
    margin-right: 30px;
}


.container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
}


.footer {
    position: fixed;
    left: 0;
    bottom: 0;
    text-align: center;
    font-weight: bold;
    padding: 20px 0;
}
.greeting {
    margin-bottom:50px;
}
.motto {
    margin-bottom: 100px;
}
.logo {
    margin: left 30px;
    height:32px;
}
@import url('https://fonts.googleapis.com/css2?family=Kanit&display=swap');
* {
font-family:'Kanit',sans-serif;
}
</style>
취소
 공유
취소
댓글 0
댓글 알림
나의얼굴