What's the most effective method for placing images and divs on top of an image in Responsive Web Design?

I have a vision for the "gateway" to my new website, which includes a striking background image. I want to overlay this image with 5 unique images arranged in a specific pattern, along with 3 text-filled divs containing links. You can see exactly what I'm envisioning by checking out this design: Link to visual representation of Gateway

It's crucial that this gateway is developed with a responsive design in mind.

I've been playing around with relative and absolute positioning techniques, but I'm struggling to determine the best approach for placing these smaller elements on top of the larger background image. Specifically, I need guidance on how to position the images and colored divs over the picture effectively. My question is: What is the most effective method for placing these elements on top of the gateway background?

If you're curious about the progress made on the live portal construction, feel free to check it out here: Link to live portal under construction

I believe I'll eventually find a solution, but I really want to do this the right way, or at least a good way.

Thank you for any assistance!

Answer №1

This scenario is one I've personally encountered in the past.

To achieve the desired effect, make sure to adjust the size of the images you wish to overlay to match that of the parent (background) image. Position the images as needed and ensure the rest of the image is transparent (consider using png24 for optimal transparency support and file size).

Follow these steps using your preferred photo editing software:

  1. Create a canvas matching the size of the background image
  2. Add the background image to the canvas as a reference (lock the layer if possible)
  3. Position the overlay image as desired
  4. Repeat for any additional overlays
  5. Delete the background image and set the canvas as transparent
  6. Export the overlay images as PNG24 format

In your CSS code, utilize the following:

img { width: auto; max-width: 100%; }

This will ensure the images are responsive, adjusting their size based on the specified width of the page container when the window is resized.

For more information on responsive or "fluid" images, visit: http://examplewebsite.com/article/fluid-images

Answer №2

To optimize your design, I recommend arranging the background image within a div container with relative positioning. After achieving the desired placement, you can then position the overlay images on top of the background using absolute positioning.

Answer №3

HTML:

<div id="container>
   <img src="..." alt="Background Image" /> /* Large Background Image */
   <a href="..."><img src="..." alt="Jacket" /></a>
   <a href="..."><img src="..." alt="Skirt" /></a>
   <a href="..."><img src="..." alt="Top" /></a>
   <a href="..."><img src="..." alt="Dress" /></a>
   <a href="..."><img src="..." alt="Second Jacket" /></a>

   <a href="..." class="yellowflag">RETAIL STORE</a>
   <a href="..." class="yellowflag">WHOLESALE USED CLOTHING</a>
   <a href="..." class="yellowflag">WIPING RAGS</a>
</div>

CSS:

#container {position:relative;}
#container > img { width: 100%; }
#container img+a         {position:absolute; top:30%; left:30%;}
#container img+a+a       {position:absolute; top:50%; right:30%;}
#container img+a+a+a     {position:absolute; top:30%; right:30%;}
#container img+a+a+a+a   {position:absolute; top:30%; left:30%;}
#container img+a+a+a+a+a {position:absolute; top:80%; left:40%;}

#container .yellowflag 
{
  /* Styling for Retail Store link */
  background-image: url(...); 
  position:absolute;top:...;left:...
}
#container .yellowflag+.yellowflag
{
  /* Styling for Wholesale Used Clothing link */
  top:...;left:...;
}
#container .yellowflag+.yellowflag+.yellowflag
{
  /* Styling for Wiping Rags link */
  top:...;left:...;
}

Answer №4

Chawk emphasized the importance of positioning the divs containing each image using position:absolute within a div that contains the background image and uses position:relative. This will ensure that the 5 images are positioned relative to their parent element rather than the entire screen.

It is important to note that the divs surrounding the images are currently displayed as blocks, meaning they occupy the full width of the parent element. To simplify things, consider setting widths for them and displaying them as inline-block elements.

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

Struggling to align the div horizontally using text-align?

I need to make the div align horizontally. .d1 { margin-left: 1rem; margin-right: 1rem; font-size: 0; text-align: justify; } .d1::after { content: ''; font-size: 0; line-height: 0; height: 0; width: 100%; di ...

Aligning columns to the right in Bootstrap, featuring an unordered list without any text wrapping

I am trying to prevent the lines from overflowing onto the next line. The details should all be on the same line. I have attempted a solution, but it's not working as expected. https://i.sstatic.net/MYgv5.png <div class="container"> <div cla ...

Hiding a div becomes impossible once it has been set to display:block

When I click on an element, I want a box to open and then when I click on a "CLOSE" button, I want it to disappear. However, I am encountering an issue where the box appears using "display:block" but does not disappear with "display:none" as intended (see ...

As the page is scrolled upwards, the custom cursor's location shifts accordingly

In developing a custom hover cursor for my video div, I am encountering an issue where the cursor does not move with my mouse and remains in place when I scroll. Could someone please review my code and identify what I am doing wrong? Additionally, I have ...

How to extract the YouTube video source using jQuery from an iframe snippet

Currently, I am attempting to extract the YouTube source from an iframe embed code and store it as a variable. Suppose my YouTube embed code looks like this: <iframe width=&quot;1024&quot; height=&quot;576&quot; src=&quot;https://w ...

Aligning the content vertically in the second row of a two-row layout

Check out this jsfiddle example I'm trying to achieve a layout with two rows, one for the header and one for the content. The header has a fixed height, and I want the content to be centered vertically in the second row. I attempted using position: ...

"Applying CSS styles to highlighted text using jQuery - how can I do it

Struggling to style selected text with CSS? Here's what I've tried so far without success in Firefox. $(document).keyup(function(){ savedRange = selection.getRangeAt(0); $(savedRange).wrap('<span style="color:red"></span>' ...

Is it possible to find a client-side management interface framework designed specifically for handling RESTful resources?

In my past experience, I have utilized ActiveAdmin with Rails for creating administration panels. As I transition to Node and plan to use Sails as a framework for a one-page app with AngularJS on the client side, the challenge remains in implementing an ad ...

Can you confirm if the explanation provided is accurate in distinguishing between inline and block-level elements in HTML?

The absence of the align attribute in the font tag is due to its status as an inline element. To center text, utilize the <center> tag instead. ...

Numerous floating elements are being displaced by the left-aligned ones, causing disarray in the layout

Here is the code snippet I'm having trouble with: html: <div class="left">left</div> <div class="left">left</div> <div class="left">left</div> <div class="right">right</div> <div class="right">ri ...

How can I create an input field that comes with a preset value but can be updated by the user with a different name?

I am in need of a solution that will enable a user to update text on a webpage dynamically. I have been unable to find any information on how to achieve this. Is there anyone aware of a method to implement this feature? Perhaps a library or utilizing Vue ...

how to center a div using css and html

Something seems off, but I just can't seem to solve it! <body> <div id="centerme"/><p>I am a div. Help me get centered.</p> </body> #centerme{ margin: auto; } ...

Expanding the Firefox scroll-bar size using html/css

I have come across similar questions on this topic, but none of the solutions provided seem to work for my specific case. My goal is to adjust the width of the scrollbar within a large div element. As the size of the div is substantial, a horizontal scrol ...

Employ the JQuery Datepicker functionality to enhance the user experience

Is it possible to integrate jQuery Datepicker into a web page that includes an iframe? And where is the optimal placement for linking the CSS and script references? ...

Integrating jQuery Tooltip with Mouseover Event

I'm currently involved in creating a map of MIT projects for an architectural firm, and facing the challenge of maintaining the red dots mouseover state even when the mouse hovers over the tooltips that appear. Presently, the mouseover effect turns of ...

Unlock the Power of Angular: Leveraging ViewEncapsulation.Native to Access HTML Elements

I am encountering an issue where I am receiving an error when trying to access an HTML element by ID. The problem arises when I attempt to access the classList upon a user clicking a button to apply a different style class to the element. The class list an ...

Methods for creating overlapping background images in breadcrumbs

I am having trouble with making the breadcrumb frame overlap the inside images. I attempted using z-index: -1, but it causes the images to disappear. Please refer to the attached image for a better understanding. Thank you. .breadcrumb { margin-botto ...

The CSS cursor style is taking precedence over the inline cursor style while dragging items in the list

I am currently utilizing the Nestable JS library and have a list of nestable items in my tree. I am trying to implement a cursor: pointer when hovering over them and a cursor: move when dragging. However, I am facing issues in getting this functionality to ...

Issue with collapsed accordion toggle functionality

HTML <div class="panel-group" id="accordion"> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a class="accordion-toggle" data-toggle="collapse" data ...

Implementing initial state checks for Alpine.js checkboxes based on x-modal is not functioning properly

Upon loading alpinejs, for some reason all checkboxes become unchecked. It's perplexing and I can't figure out why. <div x-data="{ colors: [orange] }"> <input type="checkbox" value="red" x-model="co ...