html - Div is not expanding with text -
.row { display: flex; } .col { flex: 1; } .container { display: flex; align-items: center; background-color: blue; font-size: 12px; color: #87909a; width: 275px; margin-top: 20px; margin-left: 20px; height: 70px; } .textview { height: 50px; line-height: 35px; padding-left: 13px; position: relative; border-bottom: 1px solid #cfd4d9; background-color: #fff; color: #5c6570; padding-right: 13px; margin-left: 20px; vertical-align: middle; display: inline-block; } .middle { vertical-align: middle; }
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="event.css"> </head> <body> <div class="row"> <div class=".col"> <img src="map.png" style="height: 300px; width: 300px; margin-top: 20px;"> </div> <div class=".col"> <div class="container"> <div class="textview"> <span class="middle">some text</span> </div> <div class="textview"> <span class="middle">some text</span> </div> </div> </div> </div> </body> </html>
i want create view have above? can let me know how can center white container view in blue background , how center text within white container view.
also can give me general feedback if correct way achieve layout below? want create side side views map 70% , right hand side takes 30%.
just add following css changes , remove .
col
class in html.
if need map occupy 70%
use 2 separate divs
col-1
, col-2
, assign them .col-1 {flex:1 0 70%;}
, col-2 {flex:1 0 30%;}
added fiddle better understand.
.container { display: flex; align-items: center; justify-content:center; /* added */ background-color: blue; font-size: 12px; color: #87909a; width: 275px; margin-top: 20px; margin-left: 20px; height: 70px; } .textview { height: 50px; line-height: 35px; padding-left: 13px; position: relative; border-bottom: 1px solid #cfd4d9; background-color: #fff; color: #5c6570; padding-right: 13px; margin-left: 20px; vertical-align: middle; display: inline-flex; /* added */ justify-content:center; /* added */ align-items:center; /* added */ }
.row { display: flex; } .col { flex: 1; } .container { display: flex; align-items: center; justify-content: center; background-color: blue; font-size: 12px; color: #87909a; width: 275px; margin-top: 20px; margin-left: 20px; height: 70px; } .textview { height: 50px; line-height: 35px; padding-left: 13px; position: relative; border-bottom: 1px solid #cfd4d9; background-color: #fff; color: #5c6570; padding-right: 13px; margin-left: 20px; vertical-align: middle; display: inline-flex; justify-content: center; align-items: center; } .middle { vertical-align: middle; }
<div class="row"> <div class="col"> <img src="map.png" style="height: 300px; width: 300px; margin-top: 20px;"> </div> <div class="col"> <div class="container"> <div class="textview"> <span class="middle">some text</span> </div> <div class="textview"> <span class="middle">some text</span> </div> </div> </div> </div>
Comments
Post a Comment