절대 위치 요소를 포함하는 4 개의 열

사무엘 B.

저는 게임 작업을 해왔고 어떤 경우에는 절대 포지셔닝을 사용했습니다. 특히 효과를 내기 위해 요소를 슬라이드하고 겹쳐 야하는 움직이는 애니메이션에 필요합니다.

나는 모바일에서 게임을 멋지게 만들기 위해 노력 col하고 있으며, 절대적으로 배치 된 요소를 포함하는 Bootstrap umns로 인해 발생하는 몇 가지 문제를 겪고 있습니다.

이것은 내가 얻으려는 모양입니다 (잘못 정렬 된 숫자를 제외하고), 가운데에 빨간색 사각형 행이 있습니다.

여기에 이미지 설명 입력

화면의 전체 중앙 부분 (버튼, 그림 이모티콘 및 아래 중앙에있는 카드 아이콘이있는 행)은 s를 row포함 col합니다. 이것은 일부 마크 업입니다.

<div class="col order-1 order-xl-1 col-4 col-xl-2">
    <div style="display:inline-block">
        <p class="backgrounded-text" style="white-space: nowrap; text-overflow: ellipsis;"><span id="turn_elem">...</span></span></p>
        <p class="backgrounded-text">Carta attuale: <span id="curr_card"><img class="card_icon" /></span></p>
    </div>
</div>
<div class="reaction_box order-2 order-xl-2 col col-4 col-xl-2">
    <span style="padding-left:5px!important;padding-right:5px!important" class="reaction_title">Reazioni:</span>
    <table>
        <!-- emojis ... -->
    </table> 
</div>
<div class="col order-5 order-xl-3 col-12 col-xl-3">
    <span>...</span><br />
    <span id="hidden_card">
        <img class="card_placeholder" src="..." />
    </span>
    <span id="card_stack" class="slide_to_right">
        <img class="card_placeholder" src="..." />
    </span>
    <div id="stacked_card"> 
      <img id="stacked_front" class="card_placeholder" src="..." />
    </div>
    <div id="hidden_uncovered_card_div">
        <img id="hidden_uncovered_card" class="card_placeholder" src="..." />
    </div>
</div>
<div class="col col-4 order-3 order-xl-4 col-xl-3">
        <button style="width: 49%" class="btn btn-lg btn-dark" id="doubt" @click="doubt()" :disabled="playing_animation">Dubito!</button>
        <button style="width: 49%" class="btn btn-lg btn-dark">
            Metti giù
        </button>
    </div>
</div>

imgID를 갖는다는 hidden_card(그것이 jQuery를 사용하는 커버 오른쪽 가시 슬라이드되어 적색 하나 왼쪽의 카드 인 animate위치를 조작하기). stacked_card스크린 샷에 표시되는 주요 레드 카드 인 상단에는 jQuery로 뒤집어 오른쪽으로 이동하여 겹치는 또 다른 사본이 있습니다 hidden_uncovered_card. 이것은 애니메이션이 작동하는 방식입니다. 그것들은 모두 position: absolute포지셔닝 을 사용 하고 조작하는 것에 달려 있습니다.

어떤 이유로 위의 코드로 얻은 실제 모습은 다음과 같습니다.

여기에 이미지 설명 입력

There is some space in between the three columns on the top and the one containing the red card back, and I don't understand where it is coming from. Removing all the position: absolute seems to fix this, but of course, then all the animations that depend on it stop working.

Is there any way to fix this positioning without removing the position: absolute? It'd be a pain to have to rewrite the code for all the animations, as it's working perfectly on desktop.

Here's a static webpage that contains the markup. You can turn it to mobile view (the screenshots were taken as iPhone 6/7/8 mode) and see for yourself.

click

The actual app (a beta version, that is) can be found here, in case you wanted to see how the animations work. If you need any additional information, just let me know.

Louys Patrice Bessette

Bootstrap is using a 12 colums grid.

Check how you use them.

You have:

<div class="col order-1 order-xl-1 col-4 col-xl-2">The two button on the left<div>
<div class="reaction_box order-2 order-xl-2 col col-4 col-xl-2">the emojis</div>
<div class="col order-5 order-xl-3 col-12 col-xl-3">the red cards</div>
<div class="col col-4 order-3 order-xl-4 col-xl-3">the three button on the right</div>

You should clean that!!!

Example:

  • col followed by col-4 is the same as just col-4 where col-4 overrides col.
  • order-1 and order-xl-1 is redondant if there is no order-md-3 (for example)
    Just order-1 is enought here.

For these 4 divs, make sure you use the 12 grid spaces correctly.

So about the col and col-* usage, for mobile size, you actually have 24 spaces used out of 12.

  1. 4 spaces
  2. 4 spaces
  3. 12 spaces
  4. 4 spaces

And whent the col-xl-* applies, you have 10 spaces used out of 12. Is that on purpose?

  1. 2 spaces
  2. 2 spaces
  3. 3 spaces
  4. 3 spaces

So here is what I suggest for a start:

<div class="col-3 col-xl-2 order-1">The two button on the left<div>
<div class="reaction_box col-4 col-xl-2 order-2">the emojis</div>
<div class="col-2 col-xl-3 order-3">the red cards</div>
<div class="col-3 order-4">the three button on the right</div>

which doesn't change the xl size at all, but produces this (iphone 6/7/8 mode):

여기에 이미지 설명 입력

That's a start.

그래서 비결은 클래스를 순서대로 만드는 것입니다. col-*기본에서 더 큰 특정 크기까지 ... 그리고 order-*순서도 마찬가지입니다. 그러면 마크 업을 읽을 수 있습니다.

;)


편집하다

레드 카드 가 다른 행에 표시되도록하려면 :

<div class="col-4 col-xl-2 order-1">The two button on the left<div>
<div class="reaction_box col-4 col-xl-2 order-2">the emojis</div>
<div class="col-10 col-xl-3 order-4 order-xl-3 sm-translateUp">the red cards</div>
<div class="col-4 order-3 order-xl-4">the three button on the right</div>

순서가 변경되었고 다음과 같은 추가 .sm-translateUp클래스가 있습니다.

@media screen and (max-width: 576px){
  .sm-translateUp{
     transform: translateY(-85px);
  }
}

그 결과 :

여기에 이미지 설명 입력

이제는 정말 해킹처럼 보입니다 ... (LOL)하지만 col그것이 부모 안에 갇혀 있기 때문에 .row제가 지금 생각하는 전부입니다.

따라서 각 부트 스트랩 중단 점에 대해 필요한 모든 @media 규칙 내에 해당 클래스를 정의해야합니다.

  • sm :> = 576px
  • md :> = 768px
  • lg :> = 992px
  • xl :> = 1200px

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

배열 정렬 잘못된 위치에 하나 개의 요소를 잎

분류에서Dev

어떻게 HashMap의 내부 배열의 위치를 요소를 포함하는 식별 하는가?

분류에서Dev

절대 위치 요소의 너비

분류에서Dev

테이블 셀 내부에서 Bootstrap4 / Flexbox를 사용하여 셀을 2 개 열로 분할하고 한 열은 절대 위치입니다.

분류에서Dev

절대 위치를 코딩하지 않고 다양한 크기의 구성 요소를위한 LayoutManager

분류에서Dev

절대 위치 요소를 포함하는 4 개의 열

분류에서Dev

요소의 절대 값의 합이 최대 인 대체 부호가있는 요소를 포함하는 하위 목록 결정

분류에서Dev

절대 위치 요소의 앵커 포인트를 정의하는 방법은 무엇입니까?

분류에서Dev

"위쪽", "오른쪽", "아래쪽"또는 "왼쪽"이없는 절대 위치 요소의 블록 포함

분류에서Dev

절대 위치를 사용하여 TD의 자식 위치

분류에서Dev

WP8에서 요소의 절대 위치를 얻고이를 사용하여 해당 요소를 새 위치로 이동하는 방법

분류에서Dev

각 요소를 k 개 이하의 위치로 교체하여 n 개 요소 순열

분류에서Dev

(위치 : 절대)가있는 요소의 너비 (위치 : 상대)가있는 요소 내부

분류에서Dev

절대 위치 요소 내부의 고정 위치 요소

분류에서Dev

절대 위치 요소가있는 열 사이의 예기치 않은 간격

분류에서Dev

위치 절대 요소의 100 % 너비

분류에서Dev

ng-repeat 목록 내부의 요소를 겹치는 방법-위치 : 절대?

분류에서Dev

ng-repeat 목록 내부의 요소를 겹치는 방법-위치 : 절대?

분류에서Dev

앵커의 텍스트를 절대 위치에있는 의사 요소 위에 놓기

분류에서Dev

Elm-요소의 절대 위치

분류에서Dev

IE9 / 10에서 테이블 셀 내부의 절대 위치 의사 요소가 상위 요소를 포함하지 않습니다.

분류에서Dev

조상이 절대 위치를 가지고 있음에도 불구하고 페이지에서 요소의 위치를 절대적으로 만드는 방법

분류에서Dev

절대 위치 요소를 절단하지 않고 오버플로 요소

분류에서Dev

CSS를 사용하여 절대 위치 요소를 자신의 위치 속성 위에 중앙에 배치

분류에서Dev

절대 요소 아래의 요소는 그 위에있는 절대 요소를 방해합니다.

분류에서Dev

절대 위치 요소의 높이 100 %

분류에서Dev

중심 절대 위치 의사 요소

분류에서Dev

위치 절대 요소는 위치 상대 요소 대신 페이지의 하위 요소입니다.

분류에서Dev

절대 위치가있는 요소의 공간을 차지하는 요소

Related 관련 기사

  1. 1

    배열 정렬 잘못된 위치에 하나 개의 요소를 잎

  2. 2

    어떻게 HashMap의 내부 배열의 위치를 요소를 포함하는 식별 하는가?

  3. 3

    절대 위치 요소의 너비

  4. 4

    테이블 셀 내부에서 Bootstrap4 / Flexbox를 사용하여 셀을 2 개 열로 분할하고 한 열은 절대 위치입니다.

  5. 5

    절대 위치를 코딩하지 않고 다양한 크기의 구성 요소를위한 LayoutManager

  6. 6

    절대 위치 요소를 포함하는 4 개의 열

  7. 7

    요소의 절대 값의 합이 최대 인 대체 부호가있는 요소를 포함하는 하위 목록 결정

  8. 8

    절대 위치 요소의 앵커 포인트를 정의하는 방법은 무엇입니까?

  9. 9

    "위쪽", "오른쪽", "아래쪽"또는 "왼쪽"이없는 절대 위치 요소의 블록 포함

  10. 10

    절대 위치를 사용하여 TD의 자식 위치

  11. 11

    WP8에서 요소의 절대 위치를 얻고이를 사용하여 해당 요소를 새 위치로 이동하는 방법

  12. 12

    각 요소를 k 개 이하의 위치로 교체하여 n 개 요소 순열

  13. 13

    (위치 : 절대)가있는 요소의 너비 (위치 : 상대)가있는 요소 내부

  14. 14

    절대 위치 요소 내부의 고정 위치 요소

  15. 15

    절대 위치 요소가있는 열 사이의 예기치 않은 간격

  16. 16

    위치 절대 요소의 100 % 너비

  17. 17

    ng-repeat 목록 내부의 요소를 겹치는 방법-위치 : 절대?

  18. 18

    ng-repeat 목록 내부의 요소를 겹치는 방법-위치 : 절대?

  19. 19

    앵커의 텍스트를 절대 위치에있는 의사 요소 위에 놓기

  20. 20

    Elm-요소의 절대 위치

  21. 21

    IE9 / 10에서 테이블 셀 내부의 절대 위치 의사 요소가 상위 요소를 포함하지 않습니다.

  22. 22

    조상이 절대 위치를 가지고 있음에도 불구하고 페이지에서 요소의 위치를 절대적으로 만드는 방법

  23. 23

    절대 위치 요소를 절단하지 않고 오버플로 요소

  24. 24

    CSS를 사용하여 절대 위치 요소를 자신의 위치 속성 위에 중앙에 배치

  25. 25

    절대 요소 아래의 요소는 그 위에있는 절대 요소를 방해합니다.

  26. 26

    절대 위치 요소의 높이 100 %

  27. 27

    중심 절대 위치 의사 요소

  28. 28

    위치 절대 요소는 위치 상대 요소 대신 페이지의 하위 요소입니다.

  29. 29

    절대 위치가있는 요소의 공간을 차지하는 요소

뜨겁다태그

보관