jeudi 21 décembre 2017

How to use CSS position property when drawing a card game via HTML and CSS

I am developing the solitaire card game with a web interface. I am not sure about how to use the CSS position property for positioning the elements of the game (stock, waste, foundation...) using CSS. I am using absolute position value and pixels. This is a piece of my stylesheet:

.stock {
    position: absolute;
    top: 250px;
    left: 300px;
}

.waste {
    position: absolute;
    top: 250px;
    left: 450px;
}

.tableau1 {
    position: absolute;
    top: 550px;
    left: 300px;
}

.tableau2 {
    position: absolute;
    top: 550px;
    left: 450px;
}

.tableau3 {
    position: absolute;
    top: 550px;
    left: 600px;
 }

.tableau4 {
    position: absolute;
    top: 550px;
    left: 750px;
}

 ...

.card {
    display: inline-block;
    width: 3.3em;
    height: 4.6em;
    border: 1px solid #666;
    border-radius: .3em;
    -moz-border-radius: .3em;
    -webkit-border-radius: .3em;
    -khtml-border-radius: .3em;
    padding: .25em;
    margin: 0 .5em .5em 0;
    text-align: center;
    font-size: 2.2em; /* @change: adjust this value to make bigger or smaller cards */
    font-weight: normal;
    font-family: Arial, sans-serif;
    position: relative;
    background-color: #fff;
    -moz-box-shadow: .2em .2em .5em #333;
    -webkit-box-shadow: .2em .2em .5em #333;
    box-shadow: .2em .2em .5em #333;
}

My concern is that this way it depends on the screen resolution, for instance if resolution is 640x480 does it mean elements located from left > 640px would be located at the edge of the screen? What would be the better way to locate the game elements or the CSS properties I need to take in account in order for the game to be displayed in a responsive way?




Aucun commentaire:

Enregistrer un commentaire