Arranging images in a dynamic layout, either next to each other or on top of one

Currently, I am tackling a project involving two images of the human body - one for the front and one for the back. Both images are set at a height of 80vh. The challenge lies in my use of bootstrap to align these images side by side when the screen is wide, and stack them on top of each other when the screen is narrow using col-xs-12 / col-md-6 classes. However, I find that these columns are not as responsive as I would like them to be. Ideally, I want the images to stay next to each other unless they absolutely need to be stacked. Any suggestions on how I can achieve this? Thank you in advance!


Here is the current HTML structure:

<div class="row">
    <div class="col-md-2"></div>
    <div class="col-xs-12 col-md-4" id="bodyMapFrontContainer">
        <img src="frontBodyImage.png" class="questionInputMethod" id="bodyImageFront" />
    </div>
    <div class="col-xs-12 col-md-4" id="bodyMapBackContainer">
        <img src="backBodyImage.png" class="questionInputMethod" id="bodyImageBack" />
    </div>
    <div class="col-md-2"></div>
</div>

Corresponding CSS styling:

.questionInputMethod {
    margin-left: auto;
    margin-right: auto;
    text-align:center;
}

#bodyImageFront, #bodyImageBack {
    display:block;
    max-height: 60vh; 
    max-width: 90%;
    height:auto;
    width: auto;
    margin-bottom: 10px;
    z-index:1;
    position:absolute;
}

Answer №1

WookieCoder Is this similar to what you are looking for?

Check out this Fiddle and adjust the size.
Below is the CSS to place the image in a block with a height of 60vh.

.bg-image { 
    background: #fff url('http://images.clipartpanda.com/sad-girl-stick-figure-image.png')center no-repeat;
    -webkit-background-size: contain;
    -o-background-size: contain;
    -moz-background-size: contain;
    background-size: contain;
}       
.block {
    min-height: 60vh;
} 

If you want to center the main div, try using the col-sm-offset-x class. It allows you to reposition it on smaller screens.

Does this clarify things for you?

Updated with additional media breakpoint

Here is the Fiddle with an extra breakpoint at 400px.
You can delete the code I added to display it using col-xxs-12.

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

PHP - Dynamically populating form questions based on user input

Currently, I am in the process of developing a fuel calculator form that utilizes PHP and HTML. The form is taking shape nicely, but there is one particular aspect that has me stuck. I want to incorporate a fuel perks feature that requires user input. Spe ...

Link to xpath concept

I am trying to create a hyperlink to a particular spot on a website that I do not have access to edit. Unfortunately, there is no identifiable ID near the location I want to link to, so using <a href="http://example.com/page.html#location"> will no ...

Navigating through the img src using JavaScript

Currently, I am working on a task that involves the following code snippet: <input type="file" id="uploadImage" name="image" /> <input type="submit" id="ImageName" name="submit" value="Submit"> My goal is to have the path of the selected imag ...

Ensure that both <li> elements are of equal height

I have two list elements with different content lengths, but I need them to have the same height for design purposes. Their width is relative, so I cannot determine the total height. Is there a way to use CSS to set both list elements to the height of the ...

"Enhance your web design workflow with Dreamweaver's ability to edit files

While coding in Dreamweaver CS5, I prefer using the code view exclusively. Recently, I came across the "dual screen" workspace feature which allowed me to eliminate distractions and focus solely on the main workspace with a secondary workspace in the corne ...

Challenges that arise from IE6 css issues

I am encountering an issue with the jquery slider in IE6. To see the problem, please visit the link below and click on the "dodaj u košaricu" button located at the bottom right. Then, navigate to the "košarica" tab and attempt to move the slider up and d ...

Fade in the background of table row clips using jQuery's fadeIn() method

When using the fadeIn() function to change the dimensions of a table, Firefox is clipping the background of the newly shown rows. If I click away from the tab and then return, the background is restored. This issue does not occur in Chrome. I am using Fi ...

Exploring the Differences Between Nth-CSS and Jquery

What are the advantages of using the nth function in CSS instead of applying it through jQuery, especially considering its compatibility with IE? Is it better to simply use jQuery from the start and avoid using it in a stylesheet altogether? Hopefully thi ...

Font Awesome icons within a nested accordion created using Bootstrap

I have a bootstrap accordion with 3 levels of nesting that is functioning correctly, but I want to make a change in the panel-heading div where I can use a font-awesome icon fa fa-chevron-down when the accordion is open (without affecting the nested accord ...

(Reactjs) Steps to automate submission of file upon selection

I'm having trouble figuring out how to automatically submit an image using an input field without a submit button. My current approach involves selecting the file and then submitting it automatically. Here's what I have so far: const [image, setI ...

Attempting to bind an input parameter using NgStyle in Angular version 2 and above

Issue: I am in need of a single component (spacer) with a width of 100% and a customizable height that can be specified wherever it is used in the HTML (specifically in home.html for testing): number 1 <spacer height="'200px'"></spa ...

TinyMCE: Tips for adding and highlighting text in your content!

Is there a way to insert, or even replace the current selection with some content and then have it automatically selected? Take for instance this text: Hello nice world! The user has selected nice. After clicking a button, this code is executed: editor. ...

Instructions on updating the form action depending on different radio button sets

Allow users to select one radio button from each of the three groups. Based on the values chosen, dynamically change the destination page for the submit button. Below is the code snippet: input[type=radio] { position: relative; visibility: hidden; ...

What is the equivalent of a very deep selector in TailwindCSS?

When working with the v-deep selector to customize the appearance of tiptap, a rich text editor, accessing the .ProseMirror class in SCSS would look like this: editor-content { // ... styles &::v-deep(.ProseMirror) { // ... styles } } ...

Angular Material: Switching the sidenav on and off from a separate component

How can I toggle the sidenav from another component? When the button/trigger is in the same .html file as the sidenav, it works just fine. However, when I generate new components (in my case "sidebar-left" and "topbar"), it doesn't work. To address ...

Using React-Modal in ReactJS to Transmit Properties via Image URL

I am facing a challenge passing the image URL to a modal in my React JS project. The goal is simple: upon clicking on an item from the "image attachment," the modal should display the selected image. However, using img={item.document} does not populate the ...

Positioning of CSS elements: Distributing and arranging 4 divs evenly within a single parent div

Is there a more efficient method? div { border: 2px solid black; } #main { width: 107px; height: 107px; padding: 0; text-align: center; font-size: 10px; } #tl, #tr, #bl, #br { position: relative; width: 45px; height: 45px; } #tl { t ...

Title showcasing the index of a website

Help Needed: How to Remove "Index of /" Title on Google Search for Jobbulls Website Hello folks, I recently uploaded all the files for my website and when I search for my domain name on Google, it shows a page with the title "Index of /" listing out all t ...

The utilization of `ngSwitch` in Angular for managing and displaying

I am brand new to Angular and I'm attempting to implement Form Validation within a SwitchCase scenario. In the SwitchCase 0, there is a form that I want to submit while simultaneously transitioning the view to SwitchCase 1. The Form Validation is fun ...

Retrieve data from the scss document

I'm trying to extract color values from an scss file where they are stored as variables like $base-colour:#fff444. My goal is to display these color values in a column of an HTML table. Does anyone have any suggestions on how to achieve this? ...