html - Ionic: How to center a div? -


the situation:

i making app using ionic framework. in 1 page need display image. image has horizontally centered.

attempt 1:

following documentation have divided 1 row 3 equal columns , put image in second one.

 <div class="row">     <div class="col col-33"></div>     <div class="col col-33">         <img src="{{ data.logo }}" alt="">     </div>     <div class="col col-33"></div>  </div> 

but unfortunately image far centered. tend stay in left half of screen.

attempt 2:

trying old css tricks.

<div style="margin: 0 auto;">     <img src=" {{ data.logo }} " alt="" > </div> 

but again not getting desired result.

the question:

how can center div in ionic framework?

you found answer instead:

in css:

.center {     margin-left: auto;     margin-right: auto;     display: block; } 

and add class image:

 <img src="{{ data.logo }}" class="center" alt=""> 

this way don't need adjust each image on own , find descriptive when @ html. also, not restricted specific size of image.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -