Is it possible to stack image elements on top of each other without using absolute positioning?

My current dilemma involves stacking images to create a slideshow, but the situation is proving to be more complex than expected. Simply applying position: absolute leads to undesirable results. I am unsure of any alternative solutions at this point.

Check out the DEMO here!

<div class="article photo post">
    <div class="inner">
        <div class="overlay">
            <div class="title vertical">Title</div>
        </div>
        <div class="content slideshow">
            <img src="https://dl.dropboxusercontent.com/u/3618143/2-large.jpg" style="max-width: 40vw; display: inline;">
        </div>
    </div>
</div>

<div class="article photo post">
    <div class="inner">
        <div class="overlay">
            <div class="title vertical">Title</div>
        </div>
        <div class="content slideshow">
            <img src="https://dl.dropboxusercontent.com/u/3618143/1-large.jpg" style="max-width: 40vw; display: inline;">
            <img src="https://dl.dropboxusercontent.com/u/3618143/2-large.jpg" style="max-width: 40vw; display: inline;">
            <img src="https://dl.dropboxusercontent.com/u/3618143/3-large.jpg" style="max-width: 40vw; display: inline;">
            <img src="https://dl .dropboxusercontent.com/u/3618143/4-large.jpg" style="max-width: 40vw; display: inline;">
        </div>
    </div>
</div>


.article {
    position: relative;
    float: none;
    display: inline-block;
    vertical-align: bottom;
    padding: 10px;
}

... (remaining CSS code) ...

.content img {
    max-height: 70vh;
}

Answer №1

In my opinion, setting the width of the div with the class .content to 200px (or the width of the images) would be effective. This way, the images won't have enough space to align horizontally and will stack vertically instead.

Here's an example on JSFiddle.

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 correct way to scroll to a specific div using jQuery?

Here is the button code I have: <button class="contactButton">XYZ</button> When the user clicks on this button, I want my page to smoothly scroll down to a specific section. I attempted to achieve this with the following jQuery code ...

How can you enhance your HTML elements by incorporating classes and other features?

At this moment, the code I have is: var carDiv = $("<div/>").appendTo("#content"); var eUl = $("<ul/>").appendTo(carDiv); How can I transform it into <ul data-role="listview"> content </ul> Instead of <ul> ...

Implementing CSS injection on a Next.js page during server-side rendering - tips and tricks!

I recently started working with next js. In my _app.tsx page, I have the following code: import '../styles/antd.css' import '../styles/globals.css' import type { AppProps } from 'next/app' function MyApp({ Component, pagePr ...

Adding clickable padding to a Draft.js editor can enhance the user experience and make the editing process

Is there a way to apply padding to the Draft.js Editor so that clicking on the padding area selects the Editor? If I add padding directly to the container div of the Editor, the padding displays properly but clicking on it does not enable writing in the E ...

Enhance website for Facebook tab using jQuery

I'm currently working on adapting a webpage for a Facebook tab. I've created a new page for the tab and successfully loaded the content from the targeted webpage. Everything is going smoothly, but I'm facing an issue with resizing this conte ...

Tips for displaying backend error messages on the frontend

I am facing an issue with returning error messages from the backend to the frontend in my Angular project. The specific requirement is to display an error message when the value of msisdn is not eligible for renewal. Currently, the hardcoded error message ...

Attempting to assign a new class to a <div> using JavaScript

I'm facing an issue where I need to add a class to a div without replacing the existing classes. Despite my code being correct, it doesn't seem to work as expected. function clickTab(clicked_id) { var x = clicked_id x.className += " active ...

Personalize the image upload field in a straightforward form and use carrierwave

I've been facing challenges with customizing the simple form field for image upload (Carrierwave) in my Rails application. Current design: Desired outcome: My approach involved inspecting the HTML generated by simple form helpers: <%= f.input : ...

CSS to target every second visible tr element using the :nth-child(2n)

My table has a unique appearance (shown below) thanks to the application of CSS nth-child(2n). tr:nth-child(2n) {background-color: #f0f3f5;} https://i.sstatic.net/1AnDi.png I made some elements hidden on the vID, ID, and MO_Sub tr. <tr style="displa ...

Are there ways to implement Vue.js transitions without directly setting the height in the code?

I'm having an issue with a Vue app I created where I need to make an element expand and collapse when a button is clicked. I want the effect to be smooth and animated, but using the <transition> tag alone isn't working as expected. The prob ...

Having trouble aligning my fixed div to the center of the screen

I have scoured numerous resources in search of a solution to my problem, but nothing seems to work for me. I have created a simple portfolio site where I want the word 'Developer' to be the first thing visible upon loading, followed by the portfo ...

Submitting a form with multiple rows and submit buttons does not result in the submission of the submit array

In continuation of my previous question "Why does this multiple row table submit by row? Is this correct?", I have made some modifications to the original code: <tr> <td><input type='text' name='first[1]' value=' ...

Modifying the appearance of Bootstrap 4 Nav-tabs using CSS

I have implemented Bootstrap 4 Nav-tabs as shown below: <ul class="nav nav-tabs" id="myTab" role="tablist"> <li class="nav-item"> <a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" ...

css - the art of centering span text within a rounded button

CodeSandbox: https://codesandbox.io/s/eloquent-haibt-1bnib?file=/src/main.js https://i.sstatic.net/HDtft.png I'm trying to center the dash text within a button, but I'm struggling to find a solution. html <button class="round-butto ...

Absolute positioning of a div relative to its immediate parent element

Within my code, there are three nested div elements: <div id="div1"> <div id="div2"> // contains content <div id="div3"> // includes some content with a form </div> </div> </ ...

What is the best way to eliminate the focus border using a vendor prefix?

I'm currently working on a responsive website using Bootstrap 4, but I'm struggling to remove all outlines when clickable elements are clicked. Despite my attempts with the following code snippet, it doesn't seem to work: *, *:focus { out ...

PHP code for retrieving all combobox values from a form during submission

When I submit the form, I am only able to retrieve the value of the last combo box. Is there a way to capture all the combo boxes' values? Also, I need to know how to access the value of a label. Below is the code snippet used to generate the list of ...

Adjust the placement of a small division within a larger resizable division without affecting the contents of the container

Check out this JSFiddle I created: http://jsfiddle.net/asaakius/5nGYS/7/ In the code, you'll see a small div with the id #menu containing the letter "v". When I remove this div, the textarea and textbox align perfectly and resize together seamlessly. ...

Trouble with CSS sprites displaying text alongside images

My current CSS code is set up to display images using CSS image sprites as background images. The images are displayed based on the file extension, however, the href/link text is not appearing in line and is splitting into two lines. a[href$='.pdf& ...

When the down key is pressed in a textarea, choose the list item

I have HTML similar to the following <div class="row"> <textarea id="txtArea" ng-model="input" ng-change="handleOnChange(input);getSearchField(input);" ng-click="search(input)" ng-focus="search(input);" ...