最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to move search icon of search-bar at right side of search bar in ionic 4 - Stack Overflow

programmeradmin6浏览0评论

I'm Developing a Hybrid app using ionic-4. I have my simple search page and I want to move the search icon to the right side of the ion-searchbar ponent. I have tried this with different CSS rules but i didn't find any solution.

my ionic searchbar code is as below:

<ion-header>
  <ion-toolbar>
    <ion-buttons slot="start">
      <ion-back-button></ion-back-button>
    </ion-buttons>
    <ion-searchbar showCancelButton="never"></ion-searchbar>
  </ion-toolbar>
</ion-header>

I'm Developing a Hybrid app using ionic-4. I have my simple search page and I want to move the search icon to the right side of the ion-searchbar ponent. I have tried this with different CSS rules but i didn't find any solution.

my ionic searchbar code is as below:

<ion-header>
  <ion-toolbar>
    <ion-buttons slot="start">
      <ion-back-button></ion-back-button>
    </ion-buttons>
    <ion-searchbar showCancelButton="never"></ion-searchbar>
  </ion-toolbar>
</ion-header>

Share Improve this question edited Feb 5, 2020 at 12:54 htmn 1,6752 gold badges19 silver badges29 bronze badges asked Feb 5, 2020 at 4:16 Sandip MoradiyaSandip Moradiya 7261 gold badge11 silver badges31 bronze badges 2
  • can you share your code so far? also are you using cancel option? this may help for clarity – Sergey Rudenko Commented Feb 5, 2020 at 4:24
  • @SergeyRudenko Thanks for reply, I have updated my question. I'm using cancel option also. – Sandip Moradiya Commented Feb 5, 2020 at 4:40
Add a ment  | 

1 Answer 1

Reset to default 6

Since the search-bar ponent does not have shadow dom enabled, you can manipulate the CSS of the inner ponents just fine. You just need to reset the ion-icon left CSS property and make sure you are doing this inside global.scss:

ion-searchbar ion-icon {
  right: 16px !important;
  left: auto !important;
}

If you set dir="rtl" on the html tag inside index.html, you can see that ionic does this the same way when the icon needs to be flipped:

[dir=rtl].sc-ion-searchbar-md .searchbar-search-icon.sc-ion-searchbar-md {
  left: unset;
  right: unset;
  right: 16px;
}
发布评论

评论列表(0)

  1. 暂无评论