Placing pictures one on top of the other as shown in the illustrations

Just joined this community and hoping for some guidance.

I'm working on arranging separate images in a specific layout like this. Here's my code on jsfiddle.

This is the HTML I'm using:

<body>
<div class="grid-container">
    <div class="grid-item">
        <h1>Arrangement</h1>
        <div class="garuda-container">
            <div><img class="kepala hoverable partgaruda" src="https://i.postimg.cc/vmxvnPxD/kepala.png"></div>
            <div><img class="leher hoverable partgaruda" src="https://i.postimg.cc/6qcVKggb/leher.png" alt=""></div>
            <div><img class="sayap hoverable partgaruda" src="https://i.postimg.cc/RZH3Q2Gr/sayap.png" alt=""></div>
            <div class="tameng-container">
                <img class="tameng partgaruda" src="https://i.postimg.cc/pdjDrp3F/tameng.png" alt="">
                <img class="banteng hoverable partgaruda" src="https://i.postimg.cc/52N7XqmF/banteng.png" alt="">
                <img class="beringin hoverable partgaruda" src="https://i.postimg.cc/cL9DwgDk/beringin.png" alt="">
                <img class="bintang hoverable partgaruda" src="https://i.postimg.cc/hGNp3FR9/bintang.png" alt="">
                <img class="padikapas hoverable partgaruda" src="https://i.postimg.cc/3xdjMLB9/padikapas.png" alt="">      
                <img class="rantai hoverable partgaruda" src="https://i.postimg.cc/LXd33zjD/rantai.png" alt="">
            </div>     
            <div><img class="kaki hoverable partgaruda" src="https://i.postimg.cc/C5hDcJ5G/kaki.png" alt=""></div>
            <div><img class="semboyan hoverable partgaruda" src="https://i.postimg.cc/ZKD3L8SN/semboyan.png" alt=""></div>
            <div><img class="ekor hoverable partgaruda" src="https://i.postimg.cc/fyD76D20/ekor.png" alt=""></div>
        </div> 
    </div>
    <div class="grid-item explainer">
        <h1>End Result</h1>
        <img style="zoom: 50%" src="https://i.postimg.cc/d3hQQTxM/garudapancasila.png" alt="">
    </div>
</div>

And here is the CSS I've implemented:

.grid-container {
    display: grid;
    padding: 0.5rem;
    background-color: white;
    grid-template-columns: 2fr 2fr;
}

.grid-item {
    background-color: darkslategrey;
    margin: 0.125rem;
    padding: 1rem;
    text-align: center;
    color: white;
    font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
}

.garuda-container {
    position: relative;
    width: 100%;
}

.partgaruda {
    /* position: absolute; */
    max-width: 100%;
    zoom: 25%;
}

.hoverable:hover {
    filter: drop-shadow(0 0 1.5rem white);
}

I separated the images so that each part has a drop shadow effect when hovered over (shown on jsfiddle). Am I heading in the right direction or is there a better approach to achieve what I want? Please excuse any lack of clarity as I am still new to working with HTML and CSS.

Answer №1

If you're not set on using "display: grid", the classic method with "position" is a simple and direct alternative:

.garuda-container {
  position: relative; height: 50em; width: 46.375em;
  /* Picture scaling */
  font-size: clamp(1px, calc(90vh / 48), calc(90vw / 48));
}

.garuda-container>img { position: absolute; left: 50%; transform: translatex(-50%); }
.garuda-container>img:nth-of-type(1) { top: 34.625em; width: 16.875em; }
.garuda-container>img:nth-of-type(2) { top: 34.875em; width: 41.25em; }
.garuda-container>img:nth-of-type(3) { top: 0em; width: 46.3125em; }
.garuda-container>img:nth-of-type(4) { top: 29.375em; width: 28.375em; }
.garuda-container>img:nth-of-type(5) { top: 10.3125em; left: calc(50% + 0.1em); width: 10.5em; }
.garuda-container>img:nth-of-type(6) { top: 3.8125em; left: calc(50% - 1.2em); width: 11.875em; }

.tameng-container { position: relative; }

.tameng-container>img { position: absolute; }
.tameng-container>img:nth-of-type(1) { top: 17.5625em; right: 50%; width: 7.8125em; }
.tameng-container>img:nth-of-type(2) { top: 17.5625em; left: 50%; width: 7.8125em; }
.tameng-container>img:nth-of-type(3) { top: 26.1875em; right: 50%; width: 7.8125em; }
.tameng-container>img:nth-of-type(4) { top: 26.1875em; left: 50%; width: 7.8125em; }
.tameng-container>img:nth-of-type(5) { top: 17.5625em; left: 50%; width: 15.75em; transform: translatex(-50%); pointer-events: none; }
.tameng-container>img:nth-of-type(6) { top: 23.375em; left: 50%; z-index: 1; width: 5.9375em; transform: translatex(-50%); }

.partgaruda { height: auto; width: 100%; }

.hoverable:hover { filter: drop-shadow(0 0 0.25em white) drop-shadow(0 0 0.5em yellow) drop-shadow(0 0 1.5em white); }
/* Additional effect for inactive parts on hover. Optional. */
.garuda-container:hover .partgaruda:not(:hover) { filter: blur(3px); }

body { margin: 0; min-height: 100vh; background-color: darkslategrey; display: flex; justify-content: space-around; align-items: center; }
<div class="garuda-container">
  <img class="ekor hoverable partgaruda" src="https://i.postimg.cc/fyD76D20/ekor.png" alt="">
  <img class="semboyan hoverable partgaruda" src="https://i.postimg.cc/ZKD3L8SN/semboyan.png" alt="">
  <img class="sayap hoverable partgaruda" src="https://i.postimg.cc/RZH3Q2Gr/sayap.png" alt="">
  <img class="kaki hoverable partgaruda" src="https://i.postimg.cc/C5hDcJ5G/kaki.png" alt="">
  <img class="leher hoverable partgaruda" src="https://i.postimg.cc/6qcVKggb/leher.png" alt="">
  <img class="kepala hoverable partgaruda" src="https://i.postimg.cc/vmxvnPxD/kepala.png" alt="">
  <div class="tameng-container">
    <img class="banteng hoverable partgaruda" src="https://i.postimg.cc/52N7XqmF/banteng.png" alt="">
    <img class="beringin hoverable partgaruda" src="https://i.postimg.cc/cL9DwgDk/beringin.png" alt="">
    <img class="padikapas hoverable partgaruda" src="https://i.postimg.cc/3xdjMLB9/padikapas.png" alt="">
    <img class="rantai hoverable partgaruda" src="https://i.postimg.cc/LXd33zjD/rantai.png" alt="">
    <img class="tameng partgaruda" src="https://i.postimg.cc/pdjDrp3F/tameng.png" alt="">
    <img class="bintang hoverable partgaruda" src="https://i.postimg.cc/hGNp3FR9/bintang.png" alt="">
  </div>
</div>

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 is the best way to avoid cluttering the URL with a lengthy list of HTML code when adding a navigation bar to a website

I have created a navigation bar with base.html, styles.css, and main.js. Within the navigation bar, I have included links to about.html and contact.html using: {%block content%} ... {%endblock%} However, when I click on the "About" link in the navigatio ...

The overflowing issue with the Nextjs Tailwind Marquee Component is causing a display

I've recently developed a unique nextjs/tailwind component. This component displays an isometric marquee that scrolls horizontally. However, I'm facing an issue where the content overflows to the right and causes the page to become horizontally s ...

Controling attributes during the design process

Experimenting with a basic User Control in Visual Studio 2008: I've created a Panel called Wrapper with various controls inside. Will Visual Studio be able to handle this during the design phase? public partial class TestControl : System.Web.UI.UserC ...

Display the gridview using <div> elements rather than tables

Does anyone have a code snippet that can display a gridview within a <div> element instead of a table? I would greatly appreciate any assistance with this. I am trying to create a graph similar to the one I have included and would like some functi ...

What is the best way to incorporate keyboard shortcuts into carousel operations using jQuery?

The example can be found here. I want to be able to navigate through the images using the left and right arrows on my keyboard. How can I achieve this using jQuery or CSS? This is the structure of the HTML: <div id="slider-code"> <a cla ...

How can CSS files be shared among multiple projects within Visual Studio 2012?

I am working on a Visual Studio Project Solution that includes 3 separate projects. To streamline the process and avoid duplication, I aim to have a shared CSS file for all 3 projects since they all follow the same CSS rules. Despite trying the Add As Lin ...

Navigating the translation URL in a Node.js Express app

Can someone please guide me on how to handle routing for translated URLs in a Node.js Express application? In my app.js file, I currently have the following routes. How can I improve this setup for handling URLs that change based on language, while still ...

What is the best way to ensure that the background of my sticky table th stays in place and does not scroll away

I have a dynamic table where the table body rows are loaded dynamically. The wrapper uses Bootstrap5's overflow-scroll feature to keep the table at a fixed height and scroll if there are too many rows. I managed to make the table head sticky, but had ...

"Adding jQuery functionality: displaying images in a popup on the same

Greetings to everyone here, it's my first time posting but I've been following some posts from time to time. So, hello all! I have a quick question that I haven't been able to find the answer for online. I'm dismantling a template to u ...

Utilizing HTML to call a function and fetching data from AngularJS

I've been struggling to retrieve the value after calling a function in my HTML file. Despite trying various methods after conducting research, I have not achieved success yet. Take a look at the code below: HTML: <div class="form-group"> & ...

Using the width property to style a div element

There are two div elements in my HTML, each with a specified width. However, I want both divs to take up the full space as designated in the width property, regardless of the content inside them. Currently, the divs adjust their size based on the content a ...

Having difficulty changing the value of a Select element in AngularJS

Struggling to update the select value from AngularJs. Check out my code below: <select ng-model="family.grade" > <option ng-repeat="option in options" value='{{option.id}}'>{{option.text}}</option> </s ...

Tips for switching the background image in React while a page is loading?

Is there a way to automatically change the background of a page when it loads, instead of requiring a button click? import img1 from '../images/img1.jpg'; import img2 from '../images/img2.jpg'; import img3 from '../images/img3.jpg& ...

Retrieving text data from the JSON response received from the Aeris API

I am attempting to showcase the word "General" text on the HTML page using data from the API found under details.risk.type. The JSON Response Is As Follows... { "success": true, "error": null, "response": [ ...

Changing the color variable of an object using an onClick function in JavaScript

I'm currently working on a simple game where users can draw using the keys W, A, S, and D. If you want to take a look at the progress I've made so far, here is a JSFiddle link. There's a collision function in the code that I no longer need, ...

"Enhance your webpage's speed with the simple addition of width and height attributes to image tags in

I run a unique Django platform dedicated to fostering conversations among users through messages and photos, akin to a version of 9gag. In an effort to enhance my website's performance, I recently analyzed it using GTmetrix. One area where it flagged ...

Vibrant diversity in a solitary symbol

I have customized styles to incorporate Fontawesome icons with their brand colors - for instance, the Opera icon appears in red, IE in blue, and Firefox in orange. Chrome, however, presents a unique challenge with its four distinctive colors. I am curious ...

Every time I attempt to insert a background image into a div using jQuery, I am consistently faced with a 404 error message

When I hit enter in my search bar, a new div is created each time. However, I am struggling to assign a background image to the created div as I keep receiving a 404 error in the console. Below is the code snippet I'm working with: function appendToD ...

Using CSS to cut out a triangle shape from an image

Our designer has a vision for this: However, I'm struggling to find a suitable method for creating the triangle crop effect: Implementing an :after element that spans the entire width and utilizes border tricks to form a triangle shape Creating a l ...

resizing a big image to perfectly fit the width of the screen with the help of

Is there a way to use AngularJS to automatically adjust the size of a large image to fit the screen on various devices (responsive), similar to how it is done on this website? Are there any Angular directives available for this purpose, or would I need to ...