Styling on a device can vary from how it appears on a

Using Ionic2, I have an application with messages. In a browser, the message appears like this:

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

However, when running on either an Android or iOS device, it looks different:

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

The distinguishing tail on each message is missing.

Query

I need guidance on how to maintain consistent styling and display the tail across all devices.

HTML

<ion-content padding class="messages-page-content">
    <ion-list class="message-list">
      <ion-item class="message-item" *ngFor="let item of firelist | async">
        <div [ngClass]="{'message message-me':(item.memberId1 == me.uid)}">
          <div [ngClass]="{'message message-you':(item.memberId1 == you.uid)}">
            <div class="message-content">{{item.message_text}}</div>
            <span class="time-tick">
                        <span class="message-timestamp-date">{{item.timestamp | amDateFormat: 'D MMM YY'}}</span>
            <span class="message-timestamp">{{item.timestamp | amDateFormat: 'h:mm a'}}</span>
            <div *ngIf="item.memberId1 === me.uid && item.readByReceiver === true">
              <span class="checkmark">
                                <div class="checkmark_stem"></div>
                                <div class="checkmark_kick"></div>
                            </span>
            </div>
            </span>
          </div>
        </div>
      </ion-item>
    </ion-list>
</ion-content>

CSS

Refer to:

background-image: url(/assets/message-me.png);
and
background-image: url(/assets/message-you.png);

.title-timestamp {
  font-size: 11px;
  color: gray;
}

.message-item {
  background-color: transparent;
}

.label {
    overflow: visible;
    white-space: normal;
}

... (omitted for brevity) ...

.checkmark_kick {
    position: absolute;
    width:2px;
    height:3px;
    background-color:#3BB9FF;
    left:13px;
    top:12px;
}

.time-tick {
  display:inline-block;
}

UPDATE

Following the advice given, I made the following additions:

CSS

  .tail-me {
    background-image: url(/assets/message-me.png);
    background-repeat: no-repeat;
    bottom: 0;
    right: -11px
  }

  .tail-you {
    background-image: url(/assets/message-you.png);
    background-repeat: no-repeat;
    bottom: 0;
    left: -11px
  }

HTML

<ion-item class="message-item tail-me" *ngFor="let item of firelist | async">

This results in the following appearance on the browser:

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

However, the tail is incorrectly positioned. If changed to absolute positioning, it disrupts the bubble layout entirely. The use of the left and bottom CSS properties affects the position of the message bubbles. It seems that the tail-me class may be applied to the wrong HTML tag. Any suggestions?

On both iOS and Android devices, the tail remains absent:

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

Answer №1

It appears that the Android and iOS versions may not be handling pseudo elements correctly. To resolve this issue, consider using a different approach by creating a new class element to be included in both .message-me and .message-you.

Add the class element to each message box and apply absolute positioning to ensure it is placed correctly:

.tail-me {
    background-image: url(/assets/message-me.png);
    position: absolute;
    bottom: 0;
    right: -11px
}

Additionally, for the opposite side:

.tail-you {
    background-image: url(/assets/message-you.png);
    position: absolute;
    bottom: 0;
    left: -11px
}

An absolutely positioned element inside a relatively positioned element (such as your .message) will be contained within that relative element's position.

Answer №2

I made a foolish error that caused the problem. The function does indeed work on a device. The issue stemmed from an incorrect image path, preventing the device from retrieving the image.

Previously:

background-image: url(/assets/message-me.png);

Corrected to:

background-image: url(../assets/message-me.png);

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

Dynamically Alter Notification Background

I have created a demo page with some code for a smart notification. The issue I am facing is that even though the CSS is initially set to black, I want to dynamically change it to a random color upon creation. When I try to do this in the inspector, it w ...

Transferring Data through the POST Method

Is there a way for me to send just one variable using the post method? I have retrieved the $row[id] from the database and need to include it in the form submission. We know how to send user input using dfs, but what about sending the specific $row[id] v ...

The vertical-rl writing mode fails to function properly when the website is viewed within the Facebook app

I am facing an issue with a vertical button on my website. It works fine in browsers, but when the webpage is shared on Facebook and opened within the Facebook app, the button's alignment gets distorted. How can I resolve this problem? <div class= ...

The columns in the row are not fully filling up the container

I have a container with two rows inside. One of those rows contains several columns. My goal is to have four columns per line on mobile devices, which I achieved using "row-cols-4". However, on larger screens, I want all the columns to be on the same line, ...

Utilizing v-if and splice on users to select items from v-model

After following a tutorial, I have the code snippet below that I would like to enhance: <div style="margin-top: 10px;"> v-for="task in taskItems" :key="task.id" <q-icon :name="task.icon"/> <div ...

Tips for Adjusting the Position of a DIV Element Slightly Upwards

I am having trouble positioning the home-link image in my hovering navigation bar. The URL to my blog is: . Ideally, I want the image to be aligned with the text tabs next to it, but no matter what I try, I can't seem to move the "home" icon up by abo ...

Display a spinning wheel or progress bar while the website is in the process of loading

Looking to construct a treeview using the jquery-treeview plugin but noticing it's quite time-consuming (about 5-7 seconds). I'm interested in adding a spinning wheel or progress bar to indicate loading while the page is processing. Any suggestio ...

Angular Material failing to adapt to mobile devices

My website was created using Angular Material and looks great on desktop, but is completely broken and out of place when viewed on mobile devices. I'm thinking it might be because I haven't set the column size for each element properly. Any advic ...

Issues with retrieving $_POST values from a select form in PHP

When the button is clicked, I am sending a AJAX request to my PHP page using POST method with the selected data from a SELECT element. However, I am facing an issue where my PHP IF statements are not evaluating as true. It always defaults to the ELSE condi ...

What are some ways to incorporate Chakra UI with the after pseudo-class to generate a dark overlay in my video's foreground? (Specifically in the Hero section)

I am working on creating a layer effect in front of a video using Next.js and Chakra UI. I have provided an example in Figma: Here is the code snippet: function Hero() { const videoRef = useRef(); useEffect(() => { setTimeout(()=>{ ...

Are there methods to individually style components that have been generated through the .map() function?

My goal is to style each <Tuner /> component separately, which are being rendered for each item in the this.state.notes array using this.state.notes.map(). I want to position them individually on the page, but currently they all appear together. This ...

Tips for positioning the bootstrap navbar correctly inside a container

I am having some trouble with my HTML page layout. I have a fixed Bootstrap navbar and a container with a width of 1000px. I'm trying to place the navbar inside the container, but it's not working as expected. The navbar is still taking up the fu ...

Unusual issue in IE causing rendering problems in reporting services

Currently, I am creating a report using Reporting Services 2008, MVC 2, and Ajax as my development technologies. When I generate the report, everything displays perfectly if there is data present. However, if there is no data, the report body gets cut off ...

Complete and automatically submit a form in a view using AngularJS

I have developed a basic AngularJS application that is functioning smoothly. Currently, I am looking to populate certain fields and submit the form directly from the view without requiring any user input. Below, you'll find some simplified JavaScrip ...

Contrast the objects in views.py between two distinct model objects in Django

I am currently working on a feature that compares the skills required for different job postings (such as web development, marketing, etc) with the skills of a user who is logged in. If there is a match, the job posting will be displayed to the user. The ...

When generating dynamic text boxes, a new area is always allocated for each new set of dynamic text boxes that are created

<html> <head> <script src="jquery-1.10.2.min.js"></script> <script> function AddingTextBoxes() { var NumOfText=$("#NumOfTextBoxes").val(); $('#NewlyCreatedSe ...

Encountered a problem loading resources - code 500 malfunction detected

I am encountering an issue where I consistently receive a 500 Internal Server Error message in the developer console for all CSS, image, and JS files: Failed to load resource: the server responded with a status of 500 (Internal Server Error) Despite doub ...

Interactive YouTube Video Player that keeps video playing in original spot upon clicking the button

Currently, I'm working on a project that involves combining navigation and a video player within the same div container. Here is an image link And another image link The concept is that when you click on one of the four boxes, a new video will appe ...

Modifying the Collapse Direction of Navigation in Bootstrap 4

Is it possible to change the collapse direction of the Bootstrap 4 navbar from 'top to bottom' to 'right to left'? Here is the code snippet I am currently using: <nav class="navbar navbar-light bg-faded"> <button class="na ...

Adjusting label widths in Fieldcontain with JQuery Mobile

I've done a lot of research online, and it seems like a common issue. In the past, I have tackled this problem using a <table>, but I am now looking to resolve it using CSS instead of relying on JQM's data-grid. The simple problem I am fac ...