0

I am coding an pokertable with HTML and CSS/SASS. I generated the table with the CSS code below. Now i want to add evenly distributed Buttons around the table(see sketch below). I tried it by placing them at an exact location with "position: relative", but the design won't be responsive when i do it like that. The buttons should be evenly distributed also when resizing the window.

HTML code:

    <div class="game" id="game">
    <div class="game-table" id="game-table">
        <div class="cards">
            <img class="card" src="/img/SVG-cards/ace_of_spades.svg">
            <img class="card" src="/img/SVG-cards/ace_of_spades.svg">
            <img class="card" src="/img/SVG-cards/ace_of_spades.svg">
            <img class="card" src="/img/SVG-cards/ace_of_spades.svg">
            <img class="card" src="/img/SVG-cards/ace_of_spades.svg">
        </div>
        <div class="addplayer">
            <button class="addplayer-button" id="player1">+</button>
            <button class="addplayer-button" id="player2">+</button>
            <button class="addplayer-button" id="player3">+</button>
            <button class="addplayer-button" id="player4">+</button>
            <button class="addplayer-button" id="player5">+</button>
            <button class="addplayer-button" id="player6">+</button>
            <button class="addplayer-button" id="player7">+</button>
            <button class="addplayer-button" id="player8">+</button>
            <button class="addplayer-button" id="player9">+</button>
            <button class="addplayer-button" id="player10">+</button>
        </div>
    </div>

CSS/SASS code:

body {
    margin: 0;
    background-color: rgb(223, 223, 223);
}

.game {
    text-align: center;
}

.game-table {
    position: absolute;
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 100vh;
    max-width: 1800px;
    min-height: 390px;
    max-height: 820px;
    background: rgb(8,128,6);
    background: radial-gradient(circle, rgba(8,128,6,1) 0%, rgba(38,52,38,1) 100%);
    border: 15px solid #595856;
    border-radius: 10000px;
    box-shadow: 0 0 15px black;
}

.cards {
    position: relative;
    top: 35%;
}

.card {
    display: inline-block;
    height: 30vh;
    width: 15vw;
    max-width: 230px;
    min-height: 100px;
    max-height: 250px;
    margin: 0 0;
}

.addplayer {
    
    button {
        height: 5vw;
        width: 5vw;
        min-width: 40px;
        max-width: 80px;
        min-height: 40px;
        max-height: 80px;
        background-color: rgba(128, 128, 128, 0.514);
        border-radius: 10000px;
    }
}

#player1 {
    position: absolute;
    top: 5px;
    right: 50%;
}

This is how the buttons should be placed

  • Please provide a [mre]. – ThS Nov 15 '22 at 19:45
  • You’ll need JavaScript for this, especially given the constraints imposed on the dimensions. Have you considered what the table will look like on a narrow device in portrait orientation? What research have you done and what calculations have you tried? See for example https://stackoverflow.com/questions/6972331/how-can-i-generate-a-set-of-points-evenly-distributed-along-the-perimeter-of-an It’s not trivial and you may end up with an approximate solution. – A Haworth Nov 16 '22 at 03:39

0 Answers0