Ways to keep images in line instead of moving to a new line

http://jsfiddle.net/KuFbH/

I'm attempting to have all four images displayed on a single line without wrapping to the next line. Strangely, I can't seem to achieve this even though zooming out shows it exactly as desired. How can I make this work?

My goal is to enable horizontal scrolling to view these images.

HTML

<div id="main">
    <div id="scroll">
        <div class="Wrapper">   
            <div class="scrollArea">
             <img src="">
             <img src="">
             <img src="">
             <img src="">
            </div>
        </div>  
    </div>
</div>

CSS

*{  
    font-size:100%;
    margin: 0px;
    padding: 0px;
} 

body{
    width: 100%;
    height: 100%;
}

#main{
    position: absolute; 
    top:100px; 
    bottom:100px; 
    left:0;
    width: 100%;
    background: black;
}

#scroll{
    position: relative;
    width: 100%;
    height: 100%;
}

div.Wrapper{
    position: relative;
    overflow: auto;
    width: 100%;
    height: 100%;
}

div.scrollArea{
    position: relative;
    width: auto;
    height: 100%;
}

.scrollArea img{
    max-width: 100%;
    max-height: 100%;
}

Jquery

 var totalWidth = 0;
    $('.scrollArea img').each(function(){
        totalWidth += parseInt($(this).width(), 10);
    });

    $('.scrollArea').css("width", totalWidth);

Answer №1

The reason your images are wrapping is due to the default behavior of inline elements. To prevent this, you can specify the desired behavior on the parent element:

.scrollArea {
  white-space: nowrap;
}

Answer №3

To achieve the desired layout, modify your image's style in the CSS file by setting display: inline-block;.

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

A webpage filled with HTML code, presenting an abundance of empty space towards the bottom

I have set up a Relative DIV for my entire page, but for some reason, there is a large amount of empty space at the bottom. Even though I used a background image, it's not very large, and I have already set the bottom margin to 0px. Thank you in adv ...

What is the best way to keep a bootstrap navbar fixed at the top when scrolling? (It's a bit tricky)

Check out this image of my website header. HERE Is there a way to achieve a smooth scrolling effect for the blue navbar as I scroll down the page? (Specifically just the navbar, excluding the logo and social media elements). Using position:fixed; does ...

What is the best way to customize a component in a view?

<template> <div class="about"> <Header /> <h1>Welcome to the dashboard page</h1> </div> </template> <script> import Header from "../components/layout/Header.vue"; export default { name: "dashb ...

Is the drag-and-drop feature not working properly?

I'm new to coding in Javascript and I'm attempting to insert an image inside a border created with CSS. Unfortunately, the script doesn't seem to be working properly. It's possible that there is a small error in the code causing the iss ...

The vertical loading of the post slider is causing some issues compared to the

Every post slider on this website has a unique loading feature where it loads vertically for a brief moment before fully loading. While all the styles load perfectly, it seems that the javascript may be causing this slight delay. Could this be a result of ...

How to ensure an element is always aligned at the end of a line in ReactJS, no matter the screen dimensions

I have a unique element that rotates words at a set interval. <div className="inline-block flex justify-center items-center before:content-['lore_ipsum_dolor_lore_ipsum_dolor'] drop-shadow-[0_3px_3px_rgba(0,0,0,1)] t ...

Converting HTML to PDF using Node.js without relying on PhantomJS

I'm currently creating PDF files from dynamic HTML by utilizing handlebars in my Node.js application with the html-pdf package. However, I've encountered an issue as the package is reliant on phantomjs which has now been deprecated. Unfortunatel ...

The MP4 video file is not compatible with the HTML5 video player on Internet Explorer because of encoding issues

I have a website where I used HTML5 to embed a self-hosted video without controls. Initially, the video file was 2mb and it played smoothly on all browsers. However, when I replaced it with a new video file of 16mb, the video stopped playing on Internet Ex ...

A script to continuously execute a form action in a loop

As someone transitioning from software development to web development, I find the study of web development quite confusing. Please bear with me as I ask this newbie question. My goal is to test every domain within my array (dMains) so that each domain can ...

What is the best way to pass a variable from one PHP file to another?

This question may seem like a duplicate, but I found no helpful answers elsewhere. I'm in the process of creating a website where users can respond to various types of questions. To achieve this, I've written code that displays the corresponding ...

Design your website with CSS by incorporating hanging ::before labels that feature unique formatting

I am looking to create labels that designate specific groups of words. Here are the criteria: The label should appear to the left of the word group The words should be enclosed in lines, while the label should not The words should be indented, while the ...

Encountering a challenge in Angular 8: Unable to locate a supporting object matching '[object Object]'

I am having an issue trying to retrieve the Spotify API from the current user's playlists. While I can see it in my console, when I attempt to insert it into HTML, I encounter the following error: ERROR Error: Cannot find a differ supporting object ...

Creating a text shadow effect with text that has a transparent color

I am attempting to replicate the design shown below using the CSS text-shadow property, but I keep getting a solid color outcome. I have tried using an rgba value of 255,0,0,0.0 for the font-color and text-shadow like this: text-shadow: -1px -1px 0 #0 ...

Ways to resize column widths in tree views on Odoo version 10?

I have been struggling to adjust the column width of the columns in my tree view. I have attempted a few different solutions: Trying to change the width attribute in the field tag: width="100px" or width="15%%" Using the style att ...

Why is the ajax request in JQuery initiated before the code in beforeSend is fully executed?

I have encountered an issue with my code. I am trying to get a Reload.gif to start playing on my webpage before sending an ajax request to reload the data. However, the GIF only starts playing after the success function is called. Here is the timeline of e ...

Navigation bar transforms color once a specific scroll position is reached

My website features a sleek navbar fixed to the top of the window. As users scroll past a specific div, the background color of the navbar changes seamlessly. This functionality has been working flawlessly for me thus far. However, upon adding anchor link ...

Two flexible-sized containers placed side by side, with an ellipsis displayed on the left container

Can you achieve a layout where two elements are inside a container and float side-by-side? The right element should adjust its size based on the content while the left element fills the remaining space in the container with an ellipsis to truncate overflow ...

Issue with React: Caret icon in dropdown menu shifts position when page is resized to iPad or smaller dimensions

I'm facing an issue with a styled react component that has a custom dropdown menu featuring a caret icon. Whenever I test the responsiveness of the dropdown, the caret icon ends up outside the intended area. To resolve this, I've wrapped the drop ...

Issues arise when inline elements are not behaving correctly when placed alongside inline-block elements

Among the various types of HTML elements, inline and inline-block elements have their differences. One such difference is that inline elements don't support margin-top or margin-bottom properties like inline-block elements do. However, in a specific e ...

Overlay a div on top of an image in an HTML email

To display text over an image in HTML email, I am looking for a solution since using margin or position is not working as required. Below is the code snippet I have tried: <div style="padding-right:25px;padding-left:20px"> <div style="padding-t ...