html - How can I place my icon in the middle and center of my div? -


i trying place icon in middle , center of div. i've tried text-align:center;, , vertical-align: middle;

also, i'm not sure why can't place text inside right div.

here : fiddle

my result :

enter image description here

note vertical-align property applicable inline-level elements , table-cells.

in case, align icons @ middle setting line-height each .tl-top , .tl-bot divs — equal heights.

also, in order put third div right section, position in absolutely, relative main div , align using combination of top/left , transform: translate() function.

.tl-box {      border:1px solid black;      width:239px;      height:80px;      margin:13.5px;      position: relative;  }  .tl-box .tl-top {      width:45px;      height:39px;      border-right:1px solid black;      border-bottom:1px solid black;      text-align:center;      font-size:15px;      color:#4e90cb;      line-height: 39px;  }  .tl-box .tl-bot {      width:45px;      height:40px;      border-right:1px solid black;      text-align:center;      font-size:15px;      color:#4e90cb;      line-height: 40px;  }  .tl-box .tl-right {      width:194px;      text-align:center;      position: absolute;      top: 50%;      left: calc(50% + 22px); /* 22px half of width of left box */      -webkit-transform: translate(-50%, -50%);      -moz-transform: translate(-50%, -50%);      -ms-transform: translate(-50%, -50%);      -o-transform: translate(-50%, -50%);      transform: translate(-50%, -50%);  }
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet"/>    <div class="tl-box">      <div class="tl-top"> <i class="fa fa-pencil-square-o"></i>        </div>      <div class="tl-bot"> <i class="fa fa-circle-o"></i>        </div>      <div class="tl-right">          put me in right div      </div>  </div>


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -