inflearn logo
강의

Khóa học

Chia sẻ kiến thức

Khóa học tóm tắt 30 phút năm 2022 mùa 1: HTML, CSS, Linux, Bootstrap, Python, JS, jQuery&Ajax

position : relative; 관련하여 질문드립니다.

287

dllearnfe1688

2 câu hỏi đã được viết

0

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .container{
            width: 400px;
            height: 400px;
            background-color: skyblue;
            position: relative;
            top: 10px;
            left: 10px;
        }
        .one{
            width: 100px;
            height: 100px;
            background-color: red;
            position: absolute; /*absoule의 기준점 선정은 부모에 relative 설정*/
            top: 50%;
            left: 50%;
        }
        .two{
            width: 100px;
            height: 100px;
            background-color: blue;
            position: absolute;
            top: 30px;
            left: 30px;
        }
    </style>
</head>
<body>
    <div class="container"> <!-- container 클래스를 기준점으로 잡음-->
        <div class="one"></div>
        <div class="two"></div>
    </div>
    <div class="container"> <!-- top: 10px; 적용 안됨..?--> 
        <div class="one"></div>
        <div class="two"></div>
    </div>
</body>
</html>

안녕하세요 :)

 <div class="container">를 2번 출력하면

아래의 container 클래스는 top: 10px; 이 적용되지 않는 이유에 대해서 질문드립니다.

저는 아래 container 클래스가 출력될 때 top:10px; 이 적용되어서

중간에 여백이 생길 줄 알았는데, 붙어서 출력되더라구요.

답변 부탁드립니다.

감사합니다.

HTML/CSS python javascript

Câu trả lời 1

0

wellchis

이미 해결하셨겠지만..

 

두 container 태그에 모두 top 값이 적용되어서 그런 것 같습니다만

두 번째 container에 top값을 더 주거나 하시면 될 것 같습니다.

css에 container:nth-child(2){ top:20px } 를 하셔도 되고,, 방법은 많습니다!

강의자료

0

11

1

윈도우에서 Node js를 설치하고 싶어요

0

16

0

수업 노트가 안 보입니다.

0

17

1

Python formatter 설치

0

12

1

55강 파이썬에만있는 연산자들

0

11

1

55강의 파이썬에서만 있는 연산자들

0

11

1

주말에 실행할 경우 update_economic_data_in_background에 로직 변경 필요성

1

19

1

codesandbox 처음부터 안되네요

0

624

2

codesandbox 문서 버튼이 안보여요

0

344

1

html의 input

0

344

0

HTML - input

0

242

0

현재 기준으로 쥬피터 노트북 메뉴가 안보이네요

0

316

0

20 분쯤에서 코드대로 했는데 왜 안되는걸까요ㅜ_ㅜ

0

237

0

atom 단축키 문의

0

378

1

이거 크롬 웹브라우저에 안나타나요...

0

230

1

재미있었어요.

0

231

1

facebook 컬러를 어떻게 가져오나요?

1

266

1

오류 질문드려요

1

253

1

쥬피터??가 뭔가요...

0

343

1

부트스트랩 다운 과정

2

265

1

open in browser 문의

1

303

2

{% static %} 을 해도 바뀌지 않음.

0

232

1

getElementByClass는 없나요?

2

347

1

탭을 누르는게 뭔가요?

2

407

2