Ask Your Question
3

How can I place an image on the left side and prevent text from overlapping it?

asked 2023-04-02 11:00:00 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-06-05 13:00:00 +0000

lakamha gravatar image

There are different ways to achieve this depending on the context and specific requirements, but one possible approach is to use CSS to create a container element that wraps both the image and the text, and apply a float property to the image to move it to the left side. Then, use padding or margin to create space between the image and the text. Here's an example:

HTML:

<div class="image-text-container">
  <img src="image.jpg" alt="Image description">
  <p>Text content goes here...</p>
</div>

CSS:

.image-text-container {
  overflow: auto; /* creates a block formatting context to contain floated element */
}
img {
  float: left;
  margin-right: 10px; /* creates space between image and text */
}

This will align the image to the left side of the container and add a margin between the image and the text. The overflow property on the container ensures that it expands to contain the floated image, preventing any overlapping with other content outside of it.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-04-02 11:00:00 +0000

Seen: 16 times

Last updated: Jun 05 '22