Put picture on the right side of the page?

Joined
Feb 3, 2023
Messages
1
Reaction score
0
So, i have a div with some text in it and i have it centered in the middle of the screen. That's how i want it to stay. Now i want to put a picture next to the div without moving the div from its place. Any ideas?
 
Joined
Jan 30, 2023
Messages
107
Reaction score
13
So, i have a div with some text in it and i have it centered in the middle of the screen. That's how i want it to stay. Now i want to put a picture next to the div without moving the div from its place. Any ideas?
it would be better than you share you code so that we can see and help you ...
Else :
You : can achieve this by using CSS to set the position of the image to be absolute and giving it a specific position relative to the parent container, which in your case is the centered div

CSS:
<style>
  .center-div {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
  }

  .image {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translate(0, -50%);
  }
</style>

<div class="center-div">
  Some text
  <img class="image" src="image.png" alt="Image">
</div>

In this example, the .center-div is centered on the page using absolute positioning and transform. The .image is positioned absolutely to the right of the parent container, and is vertically centered using top: 50% and transform: translate(0, -50%).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top