Achieve stacking one div on top of another without specifying a position and utilizing inline CSS only

Currently, I am working on creating a unique design for a letter that will be sent out to customers via my website. In my efforts to achieve this, I came across a simple design that caught my eye.

To view the design inspiration, visit this link

My goal is to add an image of an angle in the bottom-right corner of the letter, but I am facing some challenges. Despite using the following code snippet:

<div style="float:right; padding-top:15px;">   
  <img src="http://s017.radikal.ru/i407/1605/de/a777fd1811b5.png">
</div>

I am unable to get the image to float on top of the border as intended. Since this is for an email letter, I am restricted to using inline CSS and cannot rely on external stylesheets. Additionally, resizing the window causes the bottom-right corner image to behave erratically, as seen in the jsfiddle example provided.

   <div style="font-size: 80%; margin: 15px 0; clear: both;">
    <div style="width: 100%; border-top: 1px dotted #d8d8d8;">
        <a title="" href="http://example.com">
            <div style="margin-left: 16px; margin-bottom: -16px; padding-top: 16px;">
                <div style="width:180px;height:120px; border: 1px solid #e5e5e5;">
                    <div style="position: relative; height: 85px; text-align: center;">
                        <div style="padding: 20px;">
                            <img style="width: 32px; height: 32px;" src="http://www.iconsplace.com/icons/preview/salmon/pig-256.png">
                        </div>
                    </div>
                    <div style="height: 34px; top: 85px; width: 100%; right: 0; left: 0; background-color: #f5f5f5; border-top: 1px solid #e5e5e5;">
                        <div style="float:left; height: 34px; width: 35px; text-align: center; vertical-align: middle; line-height: 40px;">
                            <img style="width: 16px; height: 16px; border: none;" src="http://araskie.xtgem.com/file/images/16x16/Dollar.png" title="Currency">
                        </div>

                        <div style="float :left; font-size: 12px; color: #777; font-weight: bold; line-height: 1.2em; margin-top: 9px; margin-right: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; word-wrap: normal;">
                            <span style="font-family: arial,sans-serif;">some text will go here</span>
                        </div>
                        <div style="float:right; padding-top:15px;">

                            <img src="http://s017.radikal.ru/i407/1605/de/a777fd1811b5.png">

                        </div>

                    </div>


                </div>
            </div>
        </a>
    </div>

It's essential to find a solution that ensures the bottom-right corner image stays in place while covering the border seamlessly. Given the restrictions on negative margins imposed by various email services, what would be the most effective strategy to achieve this visual alignment?

Answer №1

Here is a concept that I have in mind:

<table style="border-collapse:collapse; margin-left: 16px; margin-bottom: -16px; padding-top: 16px; width:180px; min-height:120px; ">

    <tbody><tr style="outline: 1px solid #e5e5e5; height: 85px; text-align: center;">
        <td>

        </td>
<td>
  <table>
    <tbody><tr style="height: 30px;"></tr>
    <tr>

    </tr><img style="width: 40px; height: 40px;" src="http://www.iconsplace.com/icons/preview/salmon/pig-256.png">
 </tbody></table></td>

    </tr>

    <tr style="background-color: #f5f5f5; border-bottom: 1px solid #e5e5e5; border-left: 1px solid #e5e5e5;">
        <td>
            <table style="min-height: 34px; display:inline-table;">
                <tbody><tr>
            <td style="height: 34px; width: 35px; text-align: center; vertical-align: middle; line-height: 40px;">
                <img style="width: 16px; height: 16px; border: none;" src="http://araskie.xtgem.com/file/images/16x16/Dollar.png" title="Currency">
            </td>
            <td style="font-size: 12px; color: #777; font-weight: bold; line-height: 1.2em; margin-top: 9px; margin-right: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; word-wrap: normal;">
                <span style="font-family: arial,sans-serif;">some text</span>
            </td>




                <td style="right:0;bottom:0;">

                        <img src="http://s017.radikal.ru/i407/1605/de/a777fd1811b5.png">
            </td>
                </tr>
                </tbody></table>

        </td>




    </tr>


</tbody></table>

Answer №2

Apply right:0;bottom:0; to the image container

Answer №3

It seems like you may require the following solution.

<img style="width: 32px;height: 32px;position: absolute;bottom: 0;right: 0;" src="http://www.iconsplace.com/icons/preview/salmon/pig-256.png">

If that doesn't meet your needs, please let me know so I can offer further assistance.

UPDATE Upon further understanding of the issue, I recall encountering similar difficulties with newsletters in the past. The most effective approach involved structuring the content using tables to achieve the desired layout. Here are some useful resources:

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

My webpage effortlessly retrieved data without the need to manually click a button using JavaScript, and a subsequent button call was made

Could someone assist me with this issue? I am utilizing the fetch API and have it linked to a button. The problem I am facing is that even without clicking the button, my data is being fetched from the API. When I click the button to fetch data for the fir ...

Alter the uploaded picture and subsequently send the revised image through an HTML form

Currently, I am working on an HTML form that includes a file input for accepting images. My goal is to take the uploaded image from the user and make some modifications using JavaScript before submitting the modified version instead of the original one. I ...

The functionality of the Angular click event binding seems to be malfunctioning

When I click on a radio button, I want to see relevant selections. Below are the files: app.component.html <div class="col-md-3"> <b>Select Category</b><br> <input type="radio" name="colors" [(ngModel)]="typing" (clic ...

What is the significance of "HandleValidSubmit()" consistently being executed in Blazor?

After reviewing my code, I noticed that the button functionality is not behaving as expected. Specifically, regardless of whether I click the Delete or Submit button, it always triggers HandleValidSubmit() and executes UpdateQuizAsync. This causes an issue ...

Disabling modifications caused by enabling dark mode settings and plugins

After creating a website with a dark theme, I noticed that plugins like 'dark reader' and the built-in night mode of Kiwi browser on mobile are altering the colors of certain elements and removing gradient effects. Is there a way to prevent these ...

What is the process for including icons on buttons?

I have been researching how to use Font Awesome software to incorporate icons into my HTML elements, but I am uncertain about the implementation process for my specific case. Currently, I have created a basic webpage with buttons and I would like to includ ...

How can divs be styled to mimic the behavior of tables in IE6 using just CSS and HTML?

Can div elements be styled to resemble tables in IE 6 using just CSS and HTML? Unfortunately, the display properties like table, table-row, or table-cell do not work in IE 6 If it is feasible, what strategies can be employed? ...

Is there a way for me to include a transition in the text of the picture's caption?

I've been attempting to incorporate a transition:1s; and transition the text to color:#0000. The specific text I'm working with is 'Joe Doe' in the image caption below my image. I've experimented with various placements in my CSS, ...

concealing elements using negative margins on tablet devices

I have an animated element on the ipad, moving from -200px to 1500px and being hidden due to overflow-x:hidden in the browser. However, when viewing this on the ipad, I am able to scroll "off screen" and reveal the hidden items, despite setting the body a ...

Issue with background image not resizing or repeating correctly on mobile devices

My website header is not scaling properly on mobile devices, causing some issues. The background color with white text using Bootstrap and custom CSS is not extending across the screen on smartphones or when viewed in Chrome Dev Tools. As a result, two ma ...

Switch up the background hue of a multi-level dropdown menu in Bootstrap 5

Has anyone attempted to modify the background color in a multi-dropdown menu using Bootstrap 5? You can find the original code here. I am looking to change the background color for visited/active items in a multi-level dropdown menu. The code snippet belo ...

Performing code execution in MVC 5 View every 1 second

I am currently working on a MVC 5 web application and I have a question regarding performing real-time calculations in the view. Below is an example of my view code: var timeRemaining = Model.account.subscriptionEndDate - DateTime.UtcNow; Is there a way ...

Exploring the ways to retrieve the returned Dynamic scope in AngularJS

There's a specific need I have - I require a single AngularJS function that can dynamically return the scope variable based on an input parameter. When it comes to controller functions, I've come across examples of how to achieve this dynamic sco ...

Facing issues with Handsontable opening within a jQuery UI dialog?

After implementing the Handsontable plugin in multiple tables, everything appears as expected on the parent page. However, when attempting to open a dialog containing a table, the tables do not display properly (only in IE). A demonstration of this issue c ...

Challenges encountered while constructing a flexbox layout

I have a flexbox design that I am trying to create with the specific layout shown in the image: https://i.sstatic.net/Sy20K.jpg My HTML code is as follows (and I do not want to make any changes to it): <div class="wrapper"> <div class="page-h ...

The CSS hover effect for text backgrounds is acting unexpectedly when the mouse moves away

I’ve added a hover effect to an h1 tag (check out the code and demo below), but it’s acting strangely when I move the mouse away, almost flickering before returning to its original state. Any suggestions on how to smoothly transition back to its origi ...

We need to display JSON data from a URL onto an HTML page within a table format

Could someone assist me with fetching JSON data from a URL Link on Amazon AWS and displaying it in an HTML table? I am a novice at this, so please explain it easily. Below you can see the HTML code, JS code, and sample information that I would like to ex ...

Tips for retrieving the file name from the <input type="file" tag within a JSP page

I am looking to retrieve the file path from an HTML input type="file, which is selected by the user in the file dialog. <script> function OpenFileDialog(form) { var a = document.getElementById("inputfile").click(); SampleF ...

How can I ensure my button aligns to the left with the element above in Bootstrap?

Here is a JSFiddle link for reference: https://jsfiddle.net/sf4wkyx0/ The alignment of my 'Add' button with the textarea seems slightly off: https://i.sstatic.net/r7lAn.png Both elements are within a container with the class col-2, but the al ...

Display an image file using the <img src=""> tag in PHP

I am facing a small issue and could use some assistance. My goal is to display the ROW image associated with each unique ID in my database. Below is an excerpt from my PHP code: while ($row = $result->fetch_assoc()) { // Display the image ...