hawx
hawx

Reputation: 1669

CSS Metric Dashboard

I'm trying to create a dashboard displaying some simple metrics, but having a nightmare aligning the div contents.

My Code:

<style>
    body {
        background-color: #000000;
    }
    #metrics {
        width: 95%;
        margin: 20px auto;
    }
    #metrics > div {
        background-color: #1FAAAA;
        height: 200px;
        width: 200px;
        display: inline-block;
        margin:20px;
    }
    #metrics > div > div {
        font-weight: bold;
        color:#FFFFFF;
        width: 100%;
        text-align: center;
    }
    .head {
        font-size: 40px;
        width: auto;
        line-height: 35px;
    }
    .top_margin {
        margin-top: 10px
    }
    .count {
        font-size: 60px;
    }
    .diff {
        font-size: 40px;
    }
</style>

<div id="metrics">
    <div>
        <div class="head">Long Status</div>
        <div class="count">00</div>
        <div class="diff">+/- 00</div>
    </div>
    <div>
        <div class="head"><br>Status</div>
        <div class="count ">00</div>
        <div class="diff">+/- 00</div>
    </div>
</div>

I am trying to align the statuses so that they display inline. I'm guess there probably is a way to do this using CSS.

Thanks in advance.

Upvotes: 2

Views: 2080

Answers (1)

Jens A. Koch
Jens A. Koch

Reputation: 41756

I added a class for the boxes (class="box") and floated them left. Don't know if this defeats the purpose of inline-block, but in JSfiddle it aligns now properly. I also removed a dangling br (before Status) in favor of a padding in class head.

DEMO

<style> 
body {
    background-color: #000000
}
#metrics {
    width: 95%;
    margin: 20px auto;
}
.box {
    background-color: #1FAAAA;
    height: 200px;
    width: 200px;
    margin: 20px;
    font-weight: bold;
    color:#FFFFFF;
    text-align: center;
    display: inline-block;
    float: left;
}
.head {
    padding: 15px;
    font-size: 30px;
    line-height: 35px;
}
.top_margin {
    margin-top: 10px
}
.count {
    font-size: 60px;
}
.diff {
    font-size: 40px;
}
</style>

<div id="metrics">
    <div class="box">
        <div class="head">Long Status</div>
        <div class="count">00</div>
        <div class="diff">+/- 00</div>
    </div>
    <div class="box">
        <div class="head">Status</div>
        <div class="count ">00</div>
        <div class="diff">+/- 00</div>
    </div>
</div>

Upvotes: 1

Related Questions