Ionic 4: Facing issues with setting complete background image on ion-card

https://i.stack.imgur.com/3lH6h.png

I'm currently attempting to set a background image for an Ion-card in order to completely cover the card's area. However, I'm facing an issue where the background image does not cover the entire area and leaves some corners uncovered. Below is my code:

   <ion-card class="design" style="width : 43%;height: 35%;">
   </ion-card>

    Scss Code
    .design  {
     background-image: url(../../assets/icon/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3f4d5a5c4b5e5158535a7c504f460d">[email protected]</a>);
     background-size: cover;
     display: inline-block;

               }

Answer №1

Give this a shot:

#custom-design{
            background-size: 100%;
            background-repeat: no-repeat!important;
            background-size: cover!important;
            width: 105vw!important;
            height: 100vh!important;
            margin-left: -10%!important;
            background-attachment: fixed!important;
            margin-top: -10%!important;
            background-position: center center!important;
          }

TRY IT OUT

Answer №2

Essential: In order to customize the appearance of your component, you must specify the style settings within the component itself.

ion-card {
     background-image: url('assets/35.jpg');
     background-size: cover;
     (...)
}

If you are facing difficulties with the background-image while using the URL parameter, you can resolve this issue by referring to the following link:

https://example.com/vue-issues

Answer №3

The reason for this is because an ion card has a default margin of 10px surrounding it.

To resolve this issue, you can simply override the original CSS by adding your own styling to the .card-md class.

.design  {
  background-image: url(.....);
  background-size: cover;
  display: inline-block;
}

.card-md {
  margin: 0;
}

Alternatively, I suggest setting the background-position property to center instead.

.design  {
  background-image: url(...);
  background-size: cover;
  background-position: center;
}

For a visual demonstration, you can check out this demo.

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

What is the best way to align an Icon in the navbar-toggler of Bootstrap 5?

When working with Angular and Bootstrap to develop a navigation bar, I encountered an issue with aligning a user icon in the navbar. The picture below shows the problem that arises when trying to center align the user icon among other links in the navbar. ...

What are alternative methods for adjusting the value of a CSS property with alternative parameters?

When it comes to using similarities in my code, I often find myself needing a more flexible solution. For example: .position{ position:absolute; right:10px; top:20px; } This is where the idea of using a mixin comes in handy: .position(@absolute:ab ...

Issue with margin-top in combination with clear:both does not function as expected

<div style="float: left;">Left</div> <div style="float: right;">Right</div> <div style="clear: both; margin-top: 200px;">Main Data</div> What is causing the margin-top property to not work as expected for 'Main Dat ...

Angular facing issue with loading data and not displaying on time

In my project, I am facing difficulty in displaying the users' data on the user interface (UI). Despite trying to display the data, I am encountering issues. Here is the data from my users.json file: { "success": true, "summary": { "total_reg ...

What is the method to obtain the dimensions of the browser window using JavaScript?

In my JavaScript code, I am trying to retrieve the browser window size and then set the size of a div element accordingly. I have two div elements that should adjust based on the window size. For example, if the window size is 568px, div1 should be 38% of ...

An error occurred while trying to retrieve a resource from the bower_components directory using Vue.js CLI

I encountered an error in my project when trying to reference CSS and JS files. Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/bower_components/bootstrap/dist/css/bootstrap.min.css This is how my file ...

Analyzing the value of a tab with Protractor测试

Below is my HTML code showcasing a list of tabs: <mat-tab-group> <mat-tab label="A"> <app-A></app-A> </mat-tab> <mat-tab label="B"> <app-B></app-B> </mat ...

Implementing debounceTime in Angular can be done by using the debounceTime operator

I am currently working on implementing the debounceTime functionality in an autocomplete feature. My goal is to use debounceTime to minimize the number of server calls. After researching, I found 3 possible solutions which I have included snippets of belo ...

Inconsistency in naming of jQuery CSS properties

Can you explain the reason behind the difference in property names: $(elem).css('padding-top') compared to $(elem).css('marginTop') ? Wouldn't it make more sense if we use: $(elem).css('margin-top') instead? ...

Exploration of Non-height Divs

Repeatedly encountering the same issue - a fluid div with floated elements lacking a background due to having "no height." I've experimented with various solutions such as :after selectors, , and artificially setting a height, but none are particularl ...

Updating the value of a key in an object is not functioning as expected

There is a single object defined as requestObject: any = { "type": 'type1', "start": 0, "size": 10, "keywords": ['abcd','efgh'], filters: [], } Next, attempting to change the value for keyword, I updat ...

Internet Explorer displaying incorrect formatting for HTML CSS tables

Having an issue with table display on IE 9/10/11. Tested code on different browsers and platforms, everything looks good except when viewed on my HTTP server (lighttpd and python SimpleHTTPServer), the table is showing up incorrectly: var cell = $(&apos ...

Is organizing a table into separate sections helpful?

I'm currently working on a personal project using Material UI, but I have a more general query regarding table implementation. I have designed a layout in Figma that I like, but I am struggling to translate it into code. https://i.sstatic.net/NoWEB.p ...

What is the process to include a CSS file in PHP?

Can anyone guide me on how to include my CSS file in PHP? require('config.php'); $cssFile = "style.css"; echo "<link rel='stylesheet' href='/books/style.css'>"; What is the process of adding CSS to a PHP appl ...

How to prevent the 'page' output event from triggering when scrolling in ngx-datatable?

My preference is to avoid infinite scroll pagination; instead, I only want pagination to be triggered by clicking the page numbers in the footer. Since I am using server-side pagination, constantly triggering the 'page' event with every scroll ca ...

Problem with holding a dropdown button

Having trouble maintaining the position of this button within the floating button holder above my website content. How can I incorporate a drop-down menu while ensuring it stays within the same button holder? .btn-holder { backgr ...

NGRX effect in Nativescript Angular loses state when the app is suspended on iOS

While using NGRX with Nativescript Angular to manage state and fetch data from the server, I've encountered an issue when suspending the app on IOS. Whenever the app is in the middle of fetching data from the server and gets suspended, the entire proc ...

Lost navigation hover effect when media size decreases

I followed a tutorial to create a responsive navigation menu that was working perfectly here: After adding a logo and some additional elements, I noticed that the hover effect was missing when the media size changes, which can be seen here: I suspect the ...

Adjust the height of the list when including or excluding floated list items that are not in the final row

Within my ul are li elements with varying widths that wrap around inside a container into multiple rows. When removing an li element from the ul, I want the container's height to adjust dynamically in case a row is eliminated. If the removal happens ...

Arranging two classes in close proximity

I need help aligning two classes that are stacked on top of each other to be displayed side by side. Below is a screenshot of the two classes: The right class is .testm_boxes1, and the left class is .testm_boxes2. Here is the HTML and CSS code snippet: ...