0

I need your help, I try to center the text into her div verticaly, but I try all but it do not run. I share with you the default pattern.

The ultimate solution is to use padding, but I think can succeed with flexbox. I don't know, i'm blocked

body {
    background: #2F546B;
    margin: 0;
    font-family: 'Roboto', sans-serif;
}

#current {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
        flex-wrap: wrap;
}

.current_details {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    width: 200px;
    height: 300px;
    margin: 5px 5px;
    text-align: center;
    border: 2px solid red;
}

.current_details div {
    font-size: 2em;
    border: 2px solid #fdfefe;
}

.current_details div:nth-child(1) {
    -webkit-box-flex: 1;
        -ms-flex: 1;
            flex: 1;
}

.current_details div:nth-child(2) {
    color: #000;
    background: #fdfefe;
    -webkit-box-flex: 2;
        -ms-flex: 2;
            flex: 2;
}
<div id="current">
    <a ng-repeat="(key, value) in vm.currentQuotes" ng-href="#!/current/{{key}}">
        <div class="current_details">
            <div>AUD</div>
            <div>1.5045</div>
        </div>
    </a>
</div>
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
simonmnt
  • 59
  • 11

1 Answers1

2

You can make those boxes display: flex; align-items: center; justify-content: center; to center the contents vertically and horizontally.

body {
    background: #2F546B;
    margin: 0;
    font-family: 'Roboto', sans-serif;
}

#current {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
        flex-wrap: wrap;
}

.current_details {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    width: 200px;
    height: 300px;
    margin: 5px 5px;
    text-align: center;
    border: 2px solid red;
}

.current_details div {
    font-size: 2em;
    border: 2px solid #fdfefe;
    display: flex;
    align-items: center;
    justify-content: center;
}

.current_details div:nth-child(1) {
    -webkit-box-flex: 1;
        -ms-flex: 1;
            flex: 1;
}

.current_details div:nth-child(2) {
    color: #000;
    background: #fdfefe;
    -webkit-box-flex: 2;
        -ms-flex: 2;
            flex: 2;
}
<div id="current">
    <a ng-repeat="(key, value) in vm.currentQuotes" ng-href="#!/current/{{key}}">
        <div class="current_details">
            <div>AUD</div>
            <div>1.5045</div>
        </div>
    </a>
</div>
Michael Coker
  • 52,626
  • 5
  • 64
  • 64