# How to align the img to center

**URL:** <https://forum.ionicframework.com/t/how-to-align-the-img-to-center/48322>\
**Category:** ionic-v3\
**Created:** [April 4, 2016, 12:56pm UTC](https://forum.ionicframework.com/t/how-to-align-the-img-to-center/48322 "2016-04-04T12:56:42Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![shmu80](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@shmu80](https://forum.ionicframework.com/u/shmu80)\
**Post date:** [April 4, 2016, 12:56pm UTC](https://forum.ionicframework.com/t/how-to-align-the-img-to-center/48322/1 "2016-04-04T12:56:42Z")

</div>

I am implement native camera, and test with android emulator. After it snap the photo, the picture always appear in the left with small size.  
I try to adjust with scss and set in HTML, but still failed.  
Can anybody advise?

Code in scss

> .myphoto {  
> ion-content img {  
> height: 70vh !important;  
> width: auto !important;  
> align-items: center;  
> }  
> }

Code in HTML

> ```
> <ion-content padding class="myphoto">
> <img src="{{imgSrc}}" id="imgPlacement" style="align-items: center">
> 
> ```

> ```
> <button block (click)="takePhoto()">
> <ion-icon name="camera"></ion-icon>
> Take Photo
> </button>
> 
> ```

Result after takephoto  
 ![image](https://global.discourse-cdn.com/ionicframework/original/3X/1/3/13f6fe7aace8c32989f2f8fac64612e779e787bf.JPG)

---

<div class="post-metadata">

**Author:** ![xr0master](https://avatars.discourse-cdn.com/v4/letter/x/b4bc9f/32.png) [@xr0master](https://forum.ionicframework.com/u/xr0master)\
**Post date:** [April 4, 2016, 1:09pm UTC](https://forum.ionicframework.com/t/how-to-align-the-img-to-center/48322/2 "2016-04-04T13:09:20Z")

</div>

TL;DR;  
but you have scss issue

```auto
.myphoto {
img {
height: 70vh !important;
width: auto !important;
align-items: center;
}
}

```

---

<div class="post-metadata">

**Author:** ![shmu80](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@shmu80](https://forum.ionicframework.com/u/shmu80)\
**Post date:** [April 4, 2016, 1:17pm UTC](https://forum.ionicframework.com/t/how-to-align-the-img-to-center/48322/3 "2016-04-04T13:17:02Z")

</div>

May I know what do you mean `TL;DR;` and what scss issue that is? how can I fix that issue?

Thanks.

---

<div class="post-metadata">

**Author:** ![shmu80](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@shmu80](https://forum.ionicframework.com/u/shmu80)\
**Post date:** [April 4, 2016, 2:24pm UTC](https://forum.ionicframework.com/t/how-to-align-the-img-to-center/48322/4 "2016-04-04T14:24:02Z")

</div>

Hi xr0master,

Thanks for the advise. It fix my problem, but I am not applying tl, td, just modify the scss.

---

<div class="post-metadata">

**Author:** ![SDP1966](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@SDP1966](https://forum.ionicframework.com/u/SDP1966)\
**Post date:** [April 4, 2016, 5:30pm UTC](https://forum.ionicframework.com/t/how-to-align-the-img-to-center/48322/5 "2016-04-04T17:30:08Z")

</div>

I believe TL;DR = Too long, didn’t read

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [April 5, 2016, 6:23pm UTC](https://forum.ionicframework.com/t/how-to-align-the-img-to-center/48322/6 "2016-04-05T18:23:09Z")

</div>

So the scss is a little off.

```auto
img{
  height: 70vh;
  width: auto;
  margin: auto;
  display: block;
}

```

Since images are displayed inline, we need to change their display to block and we can set their margin to auto.

> **[Ionic 2 Tabs Starter](https://codepen.io/mhartington/pen/BKmrvP?editors=0110)**
>
> The Ionic 2 Tabs Starter Forked from \[Tim Lancina\](http://codepen.io/tlancina/)'s Pen \[Ionic 2 Tabs Starter\](http://codepen.io/tlancina/pen/EPBdVE/)....

---

<div class="post-metadata">

**Author:** ![prem-shankar](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@prem-shankar](https://forum.ionicframework.com/u/prem-shankar)\
**Post date:** [February 6, 2019, 1:57pm UTC](https://forum.ionicframework.com/t/how-to-align-the-img-to-center/48322/7 "2019-02-06T13:57:37Z")

</div>

thanks sir for like these supports

---

<div class="post-metadata">

**Author:** ![MaBbKhawaja](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mabbkhawaja/32/120141_2.png) [@MaBbKhawaja](https://forum.ionicframework.com/u/MaBbKhawaja)\
**Post date:** [February 7, 2019, 7:37am UTC](https://forum.ionicframework.com/t/how-to-align-the-img-to-center/48322/8 "2019-02-07T07:37:59Z")

</div>

display: block;  
margin: 0 auto;  
thats all

---

<div class="post-metadata">

**Author:** ![sandeepjohnsonk](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sandeepjohnsonk/32/127371_2.png) [@sandeepjohnsonk](https://forum.ionicframework.com/u/sandeepjohnsonk)\
**Post date:** [July 17, 2019, 9:48am UTC](https://forum.ionicframework.com/t/how-to-align-the-img-to-center/48322/9 "2019-07-17T09:48:59Z")

</div>

img{  
height: 70vh;  
width: auto;  
margin: auto;  
display: block;  
}

thanks man

---

<div class="post-metadata">

**Author:** ![wildbananastiia](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/wildbananastiia/32/135609_2.png) [@wildbananastiia](https://forum.ionicframework.com/u/wildbananastiia)\
**Post date:** [September 11, 2020, 2:11pm UTC](https://forum.ionicframework.com/t/how-to-align-the-img-to-center/48322/10 "2020-09-11T14:11:00Z")

</div>

In my case I used ion-grid and ion-img to center the image.

```auto
<ion-grid>
    <ion-row>
        <ion-col size="4" offset="4">
          <ion-img [src]="assets/logo" alt="logo-image"></ion-img>
        </ion-col>
   </ion-row>
</ion-grid>

```

You can change your code to

```auto
<ion-content padding class="myphoto">
 <ion-grid>
    <ion-row>
        <ion-col size="4" offset="4">
          <img src="{{imgSrc}}" id="imgPlacement">
        </ion-col>
  </ion-row>
...
</ion-grid>
</ion-content>

```

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 8:54pm UTC](https://forum.ionicframework.com/t/how-to-align-the-img-to-center/48322/11 "2021-07-19T20:54:08Z")

</div>

Closed on July 19, 2021, 8:54pm UTC


