picture located in the top corner of the page within the diva triangle shape

Is there a way to position my photo on the same level as a div and have it overlap slightly?

<div id='triangle-topleft'>
   <img id="photo" src="photo.png">
</div>
#triangle-topleft {
    width: 0;
    height: 0;
    border-top: 350px solid #66CCFF;
    border-right: 350px solid transparent;
    position: absolute;
    left: 0%;
}
#photo {
    position: absolute;
    left: 0%;
    float: left;
}

DEMO

Answer №1

Include the rule transform: translateY() for the #photo element.

Additionally, update the position: absolute property to position: relative for the #triangle-topleft element.

#triangle-topleft {
    width: 0;
    height: 0;
    border-top: 350px solid #66CCFF;
    border-right: 350px solid transparent;
    position: relative;
    left: 0%;
}

#photo {
    position: absolute;
    left: 0%;
    float: left;
    transform: translateY(-30%);
}
<div id='triangle-topleft'>
   <img id="photo" src="https://st.depositphotos.com/2000885/1902/i/600/depositphotos_19021343-stock-photo-red-heart.jpg">
</div>

Answer №2

Make sure to include this in your #photo section: top: -350px;

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 HTML element identifies the beginning of a particular section?

It has been suggested that Google frowns upon using identical content across multiple websites. Is there a method to mark or label a section of content with its "source"? For example, an attribute might look like this: <div original-content="http://s ...

What is the best way to implement dynamic generation of Form::date() in Laravel 8?

Is there a way to dynamically generate the Form::date() based on the selection of 1? If 1 is selected, then display the Form::date() under the Form::select(). However, if 0 is selected, then hide the Form::date() in this particular view. For example: Sel ...

"Remaining Elements" within a CSS Design

I am faced with a challenge where I have 4 elements nested inside a container element. The height of the container should be set to 100% of the browser window. The inner elements need to stack vertically, with the first two and last elements having a natur ...

Requiring a compulsory field in PHP and MySQL

I am facing an issue with the following query: $tww_update_sql = "UPDATE `telesales_anc` SET `Ime` = '".$_POST['Ime']; I also have a form with a submit button structured like this: <form id="contact" method="post" action="ANC_pozivanje ...

Step-by-step guide for dynamically including dropdown options

Is there a way to dynamically add a dropdown using JavaScript? I currently have a dropdown with numbers that creates another dropdown when selected. However, I want to add the dynamic dropdown through JavaScript. How can I achieve this? Below is the PHP ...

Enhancing Kendo Grid with Checkbox Columns

I am facing a situation with my kendo grid where I need to insert two checkbox columns in addition to the existing set of columns. <script id="sectionPage" type="text/kendo-tmpl"> @(Html.Kendo().Grid<SectionPageModel>() .Na ...

Tips for creating a seamless Bootstrap collapse effect

I have noticed a slight flicker in the content collapse when using this code. Is there a way to make it collapse more smoothly? <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script ...

How can one utilize the ejs template engine for node js to render an image tag on a webpage?

Let me provide some context: I am currently working with node.js using the express framework and integrating mongo along with passport.js for authentication. Essentially, I have successfully enabled users to log in to my app using Facebook login and retri ...

Adjust the width of the graphics on both sides of the text based on the length of the text content

Is there a way to center an H1 tag between two graphics using CSS or jquery/javascript? The width of the H1 text will vary depending on the page. The dot on the left should remain at the edge of the site, and the line should extend to meet the edge of the ...

Map through the index and render the component while closing the tag

I have a piece of code that I'm working on. How can I dynamically add a tag based on the index? My goal is to create a grid with 3 columns. <div> {items.map((row, i) => ( {i % 3 === 0 && <div className={'grid-cont ...

Customizing HTML element tags in MUI: Best practices

Using the most recent version of MUI (v5) and incorporating CssBaseline from @mui/materials. Typically, in CSS, I would set up my styles like this: body, html, #root { width: 100%; height: 100%; min-height: 100%; margin: 0; padding: 0; font-siz ...

Display the HTML code in its formatted text output

I am currently facing an issue while trying to take input from the user using the WYSIWYG text editor plugin. When I attempt to display the text in a label or paragraph, all the HTML tags become visible. For instance, @string str = "<b>sample text&l ...

CSS/jQuery animation alignment problem

Exploring an animation using CSS transitions and jQuery has been my recent project. The concept involves presenting the user with clickable divs to load a new page. When a div is clicked, it expands to cover the entire screen and transition to the next pag ...

Calculating the time difference in days, hours, minutes, and seconds between two UNIX timestamps

I have a special occasion coming up, and the date and time for this event are stored in a Unix timestamp format. Instead of relying on a plugin like modern.js, I am trying to figure out the time difference between today's date and the event date usin ...

Child div height (with embedded iframe) - issue with responsiveness

I have been working on a simple code for a day now, trying to solve a problem with no progress :( My goal is to display an iframe with a background image. However, the snippet code I have is not showing the background image as intended. You can view the li ...

Opencart admin URL customizer (Eliminate index.php?route="")

Is there a way to conceal the index.php?route="" & user_token="" links on my Opencart admin page? I would like it to display as something like admin/dashboard instead of admin/index.php?route=common/dashboard&user_token="" ...

PHP function unexpectedly prints out HTML content

In my html code, I have embedded a piece of php which is meant to dynamically change the styling of a tag based on the data from the URL. The specific scenario involves an html login form structured as follows: <form class="userdata" action=& ...

Issue encountered when submitting form: Error identified as "Unexpected string expression without template curly in string"

As a novice in React.js, I am facing an issue where setState is not functioning properly when submitting a form. Any suggestions on how to resolve this problem? > class Home extends Component{ constructor(props){ > super(props) > ...

What is the best way to modify the inline style width of a table td from pixels to percentage in order to make it

<table> <tr style="height:15pt;"> <td style="width:229pt;border-style:solid;border-width:0pt;padding:3pt 9pt 3pt 0pt;" valign="bottom" bgcolor="#c0c0c0"><p style="font-family:Times New Roman, serif;font-size:10pt;font-style:norm ...

How can I modify the color of a jQuery Mobile Select menu?

Is there a way to dynamically modify the color (background and text) of a single select menu in jQuery Mobile, without impacting other elements with the same class? I've experimented with various approaches, such as: $('#select').css({color ...