The image inside an Ionic card's header will automatically adjust its size when text is added

Two cards are currently being displayed on the page:

<ion-header>
    <ion-navbar>
        <ion-title>Home</ion-title>
    </ion-navbar>
</ion-header>

<ion-content padding>
    <ion-card class="offersCard">
        <ion-card-header>
            <b>Company Name</b>
      <br/>
      <b>Dealer</b>
    </ion-card-header>
    <ion-card-content>
      <div>
        <div class="floatLeft imgStyle">
          Image
        </div>
        <div class="floatRight">

          <div>
          Offer Descriptions:
          <br/>
          Offer Descriptions:... 
          Offer Descriptions:...
          Offer Descriptions:... 
          Offer Descriptions:...
          Offer Descriptions:...
          </div>
        </div>
      </div>
      <div>
        <div class="floatLeft alignTxt">
          Price:
          d
        </div>
        <div class="floatRight fullBtn">
          <button ion-button primary>CHECK OFFER</button>
        </div>
      </div>
    </ion-card-content>
  </ion-card>
  <ion-card class="offersCard">
        <ion-card-header>
            <b>Company Name</b>
      <br/>
      <b>Dealer</b>
    </ion-card-header>
    <ion-card-content>
      <div>
        <div class="floatLeft imgStyle">
          Image
        </div>
        <div class="floatRight">

          <div>
          Offer Descriptions:
          <br/>
          Offer Descriptions:
          </div>
        </div>
      </div>
      <div>
        <div class="floatLeft alignTxt">
          Price:
          d
        </div>
        <div class="floatRight fullBtn">
          <button ion-button primary>CHECK OFFER</button>
        </div>
      </div>
    </ion-card-content>
  </ion-card>
</ion-content>

The issue arises when a card with lengthy description text is displayed, causing it to resize and misalign instead of maintaining the specified height and weight in the SCSS file:

.offersCard{
  .floatRight{
    float: right;
    white-space: normal;
    margin-left: 4em;
  }
  .floatLeft{
    float: left;
    width: 10em;
    vertical-align: middle;
  }
  div{
    display: flex;
  }
  .imgStyle{
    width: 150px;
    height: 150px;
  }
  .fullBtn{

    float: right;
    margin-right: 0em
  }
  .alignTxt{
    margin-top: 1em;
  }
}

https://i.stack.imgur.com/kKwx5.png

Furthermore, despite setting the "Check Offer" button to float to the right, it appears at the center of the card.

For a complete functioning example, please visit this StackBlitz link

Answer №1

Make sure to check out the latest version at https://stackblitz.com/edit/ionic-acboxj

It is important to define the width for floatRight

.floatRight{
    float: right;
    white-space: normal;
    margin-left: 2em;
    width: calc(100% - 150px - 2em);
}

Answer №2

Take a look at the latest https://stackblitz.com/edit/ionic-plo3ns

Make sure to define the justify property for the fullBtn class

.fullBtn{
    justify-content: flex-end;
    float: right;
    margin-right: 0em;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to dynamically modify ion-list elements with Ionic on button click

Imagine having 3 different lists: List 1: bus, plane List 2: [related to bus] slow, can't fly List 3: [related to plane] fast, can fly In my Ionic Angular project, I have successfully implemented the first ion-list. How can I dynamically change th ...

What is the best way to prevent buttons from shifting when I enlarge the font size in HTML?

Is there a way to make buttons increase in size when hovered over without causing the other buttons to shift to the side? I've tried using the following code to achieve this but it's not working as expected: <style> button{transition-d ...

Step-by-step guide for adding an icon to the corner of a Material UI button

Is there a way to position an icon in the corner of a Material UI button in React? Currently, I have the icon next to the title but I would like to move it to the lower right corner of the button. Any suggestions on how to achieve this? Thank you! export ...

How can I ensure that my SVG Image perfectly fits within the Parent wrapper div?

I've been grappling with the following code snippet. I'm struggling to make my SVG image fit within my container div. .img { margin: 0; padding: 0; overflow: hidden; width: 500px; position: relative; } img { top:0; ...

CSS for mobile devices not loading until the device is rotated

My website, redkrypt.com, is functioning perfectly on my laptop. However, I am facing an issue where the css file will only load on my iPhone 4S after I rotate it once. Once I do this, the website works both vertically and horizontally. I have tried variou ...

Is it recommended to employ @media print for a webpage dedicated exclusively to printing purposes?

Imagine a scenario where I have a specific page featuring a print button. Clicking on this button redirects me to a separate page with the same content, optimized for printing purposes. Instead of using @media print directly on the original page due to n ...

Assign a class to a newly created element using JavaScript

I have a unique element that I've created using the code below: connectedCallback() { var custom_element = document.createElement('Div'); custom_element.class = 'element demo3'; this.appendChild(custom_element); } Howeve ...

Issue with organizing columns in Plotly-Dash using personalized CSS

I expected the code below to create three adjacent drop-down menus under a tab labeled Setup, but I'm actually seeing them stacked on top of each other. What mistake am I making? Any guidance would be highly appreciated! I've provided the releva ...

What is the method for customizing the NavBar color using CSS?

Hi there! I recently came across a responsive multi-level menu that caught my eye. After copying the CSS and JavaScript exactly, I ended up with this NavBar. The issue I'm facing is changing the default color (which is green) to another color. Here&ap ...

Changing the color of a div while implementing a show and hide effect in JavaScript

I have designed a checkout system with three distinct parts - shipping information, billing information, and order confirmation. These sections are all on the same page, allowing for a seamless flow during the checkout process. Once a customer completes t ...

Adjust the positioning of the content within each card inside the modal box

I require assistance in adjusting the CSS for different cards within the modal box. I would like all cards to have consistent column width for various content within them, creating a symmetrical appearance. Currently, the cards appear staggered. Also, plea ...

Having Trouble Redirecting to Another Page from My Ionic Framework Controller?

Struggling to figure out why my app isn't switching to another page when clicking in my controller. Any help or pointers on what I might be missing or doing wrong would be greatly appreciated! Here's the code snippet from my app.js file: $s ...

I desire my grid to exhibit an identical appearance to that of the jquery datepicker

I have an interactive element called the "open grid" that, when clicked on, reveals a grid of buttons. I'm looking for help with coding it so that instead of being displayed below the textbox, the grid of buttons can be hovered over the "open grid" li ...

When utilizing Angular CDK virtual scroller, an error occurs stating that @angular/core/core does not have an exported member 'ɵɵFactoryDeclaration'. Can anyone explain why this is happening

After adding CDK Virtual Scroller to my ionic 5.3.3 project using the command: npm add @angular/cdk The version installed is: "@angular/cdk": "^13.0.2" The scroller viewport contains an ion-item-group: <ng-template #showContentBlo ...

poor scrolling performance when transitioning focus between elements in the interface

Looking for some assistance? Check out this codepen. I'm currently working on a search bar widget that allows navigation from the input field to the search results, displayed as a series of divs. The navigation is controlled via jquery, where the foc ...

Elevate the block when encountering errors in HTML/CSS

Here is a picture of what I want, and below I will provide a more detailed description: Link to the image (I cannot paste it here) I am explaining the elements involved. There are three main components: 1) The topmost text "Bla bla bla bla" 2) The butt ...

Activate modifications in a distinct column?

I've been exploring a solution to achieve a similar functionality where clicking or hovering on headings in a column brings up corresponding text in another column. My idea is to use list items with a carousel for this purpose, but I'm facing so ...

Persistent header feature in AdminLTE 3: Easily navigate while scrolling

I am looking to make the elements in the red box on the left side of the page fixed so that as users scroll, they remain at the top of the page. I have attempted to use both the fixed and sticky properties, but neither seem to be working for me. Here is a ...

Enable the bottom footer to expand along with the content to support a dynamically growing page

I followed a tutorial on keeping footers at the bottom of a webpage (http://matthewjamestaylor.com/blog/keeping-footers-at-the-bottom-of-the-page) to create a site with a fixed footer. However, I encountered an issue when there is more content than can fit ...

Applying Border Radius to JavaFX Components for a Unique Background Effect

When I apply the CSS properties -fx-border-radius and -fx-border-width to a basic GridPane, the background in the corner does not get "cut off". The following is the CSS code being used: .payload { -fx-hgap: 20px; -fx-padding: 40px; -fx-back ...