[SOLVED] Automatic Div Height ?

Game development with Board Game Arena Studio
Post Reply
User avatar
Badguizmo
Posts: 76
Joined: 11 October 2020, 14:27

[SOLVED] Automatic Div Height ?

Post by Badguizmo »

Hello everyone.

It is me again for another beginer question ;)

I am creating a card game.
My tpl file contains some divs which represent my board, the opponent board, ... :

Code: Select all

<div id="opponentBoard" class="grid-container-center">
            <div id="opponentBoard1" class="player-rift grid-border"></div>
            <div id="opponentBoard2" class="player-rift grid-border"></div>
            <div id="opponentBoard3" class="player-rift grid-border"></div>
            <div id="opponentBoard4" class="player-rift grid-border"></div>
            <div id="opponentBoard5" class="player-rift grid-border"></div>
            <div id="opponentBoard6Empty" class="player-rift grid-container-guild-owned"></div>
            <div id="opponentBoard7Empty" class="player-rift grid-container-guild-owned"></div>
        </div>
The CSS class are :

Code: Select all

.grid-container-center {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
    width: 1225px;
    justify-items: center;
    position: relative;
    grid-auto-rows: minmax(125px, auto);
}
.player-rift {
    position: relative;
    float: left;
    width: 168px;
    height: 0px;
    margin: 0px;
    grid-auto-rows: minmax(125px, auto);
}
(.grid border only for graphical testing purpose)
I am adding cards on JS with dojo to the differents divs :

Code: Select all

template : var jstpl_elemental='<div class="card-elemental card-normal card_${guildId}_${cardValue}" id="card_${cardId}"></div>';
dojo.place(this.format_block('jstpl_elemental', {
                guildId: GuildId,
                cardValue: cardValue,
                cardId: card_Id
            }), 'opponentBoard2','last');
I have tried multiple ways but I can't manage to make my div to adapt their height to the child.

Is it possible to have done automatically (doesn't work for me at the moment) or does it have to be done manually (which I started to do) ?

(I have also the same question to have the cards to be centered inside the divs ... I have to use "slideToObjectPos" with an offset.)

Thank you for reading (and helping :D)
Last edited by Badguizmo on 02 April 2021, 16:48, edited 1 time in total.
Official BGA developper newb :oops:
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: Automatic Div Height (and centering) ?

Post by Tisaac »

Just remove the height :0px, why would you put that in the first place ??
User avatar
Badguizmo
Posts: 76
Joined: 11 October 2020, 14:27

Re: Automatic Div Height (and centering) ?

Post by Badguizmo »

Hello Tissac.

Good question :?

But commenting it doesn't seems to change anything ... :cry:

I will dig more.
Official BGA developper newb :oops:
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: Automatic Div Height (and centering) ?

Post by Tisaac »

Badguizmo wrote: 02 April 2021, 11:19 Hello Tissac.

Good question :?

But commenting it doesn't seems to change anything ... :cry:

I will dig more.
What's the game name on the studio ?
User avatar
Badguizmo
Posts: 76
Joined: 11 October 2020, 14:27

Re: Automatic Div Height (and centering) ?

Post by Badguizmo »

Riftforce.

You should have the access now (RO, tell me if you want RW).
Last edited by Badguizmo on 02 April 2021, 13:41, edited 1 time in total.
Official BGA developper newb :oops:
User avatar
fafa-fr
Posts: 383
Joined: 22 December 2013, 21:58

Re: Automatic Div Height (and centering) ?

Post by fafa-fr »

Badguizmo wrote: 02 April 2021, 11:19 But commenting it doesn't seems to change anything ... :cry:
Just to make sure, did you do a hard-refresh of your browser (Ctrl-F5 or Ctrl-Shift-R) to be sure your new css was used?
User avatar
Badguizmo
Posts: 76
Joined: 11 October 2020, 14:27

Re: Automatic Div Height (and centering) ?

Post by Badguizmo »

Hello fafa.

Yes, hard refresh, reloading everything from game page and also an express stop then express start to be sure ...

I surely made something wrong, but what ? :shock: :shock:
Official BGA developper newb :oops:
User avatar
chriskang
Posts: 7
Joined: 10 March 2021, 02:20

Re: Automatic Div Height (and centering) ?

Post by chriskang »

@Badguizmo the main reason why your parent div doesn't grow with the content is because your child div (the card) has a "position: absolute" in the .card-guild CSS class.
When an element has an absolute position it is removed from the page flow and is considered to have 0 size.
Please read this :
https://developer.mozilla.org/en-US/doc ... S/position
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: Automatic Div Height (and centering) ?

Post by Tisaac »

chriskang wrote: 02 April 2021, 14:20 @Badguizmo the main reason why your parent div doesn't grow with the content is because your child div (the card) has a "position: absolute" in the .card-guild CSS class.
When an element has an absolute position it is removed from the page flow and is considered to have 0 size.
Please read this :
https://developer.mozilla.org/en-US/doc ... S/position
Yeah I was suspecting that but there were no position absolute in the css he first posted here :)
User avatar
Badguizmo
Posts: 76
Joined: 11 October 2020, 14:27

Re: Automatic Div Height (and centering) ?

Post by Badguizmo »

arf .....
so much to learn :o
(And I forgot to put the css class for the card in the question :oops: )
Thank you all ;)

I will check/correct that tonight and update the topic

EDIT : ok it was the position.
Thank you again ;)
Official BGA developper newb :oops:
Post Reply

Return to “Developers”