left-floating div

I am currently working on designing a page that requires multiple columns to be displayed. The columns should float left and never appear stacked on top of each other. Ideally, I would like the columns to extend beyond the screen without a scrollbar, making the excess content inaccessible.

However, I am facing an issue where my second column is appearing under the first instead of beside it.

<div id="container">

    <div id="menu">
    </div>

    <div id="book">

        <div id="column1" class="column_n">
        </div>

        <div id="column2" class="column_n">
        </div>

    </div>

</div>

CSS:

body {
    margin: 0;
    padding: 0;
    border: 0;
    font-family: Verdana;
    font-size: 20px;

}

.column_n {
    width: 480px;
    margin: 20px;
    float: left;
}

Answer №1

To achieve the desired layout for your divs, it is essential to determine the appropriate width and margin values:

For example:

http://example.com

This is how your #box or container should look with a width of 1200px:

http://example.com

Answer №2

For sorting columns left to each other, set the position to relative and float left. To hide overflow of the body, use overflow: hidden. Use auto for wrapping with the same length dimension as the child element.

Answer №3

When floating left, everything is in order but the height of column_n remains small. Additionally, there seems to be an issue with scrolling.

Answer №4

Your code appears to be free of issues, with the only exception being the width of the div element: http://jsfiddle.net/XrY8U/

I personally enjoy adding background-color to my CSS for debugging purposes, as well as utilizing Chrome DevTools to inspect element sizes.

It is possible that you do not have enough width (2*480 + 4*20 = 1040 px) available for your columns. Typically, websites are designed to fit within 940 or 960 px containers.

Answer №5

To clarify, you are working with a set number of columns and only want the ones that fit within the browser window to be visible.

If you specify the heights of your columns and their containers, you can use overflow on the container div. Any columns that exceed the window width will not be shown (tested in chromium). If you resize the browser, those hidden columns may reappear. http://jsfiddle.net/rqdzK/1/

If your goal is to have all columns displayed regardless of screen size, consider using relative widths. Ensure that the total width adds up to 100% (keep in mind that on IE, 100% may be too wide, so aim for 99.5% or slightly less). http://jsfiddle.net/MqFRB/2/

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

Ensure that jquery.load is executed before the HTML content is loaded

Recently, I encountered a situation where I had a bootstrap navbar stored in a separate file, specifically named navbar.html. I utilized Jquery.load() to load this navbar into my HTML page. At the bottom of my HTML page, I included the following code: &l ...

An illustration of the fundamental concepts of require.js

main.md <markdown> <head> <script data-main="script" src="http://requirejs.org/docs/release/2.1.8/minified/require.js"></script> </head> <body></body> </markdown> script.css defi ...

Can pure Javascript be used to integrate Bootstrap pagination into a Bootstrap table?

I have created a custom JavaScript code to generate a Bootstrap table with hardcoded values. Now, I am looking to implement Bootstrap pagination using JavaScript only. var table = document.createElement("table"); table.className = "table"; var the ...

Hover to reveal stunning visuals

Can anyone help me figure out how to change the color of an image when hovered over using HTML or CSS? I have a set of social network icons that I want to incorporate into my website, and I'd like the icon colors to change when the mouse moves over th ...

Issue with md-stretch-tabs in Angular-Material causing a problem

I am in the process of developing an Angular-based application. ISSUE: I included md-stretch-tabs in my md-tabs element, but when I switch to tab#2, the tab retracts as if there is not enough space to flex. Is this problem related to dependencies or the c ...

What is a creative way to get rid of old content on a webpage using jQuery without relying on the

As I work on my crossword project, I have almost completed it, but encountering a problem. Within my HTML code, I have a select list that loads a .JSON file using Javascript. <form method="post" id="formulaire"> <div class="toto"> <sel ...

Joomla CSS styling malfunctioning

I've been exploring the creation of an in line menu using Joomla 1.6 and CSS. The issue arises when Joomla removes <span class="dmenu"> from the document before saving, despite having all cleanup options turned off. This led me to try a couple ...

Access the website by logging in with idhttp

I'm attempting to log in to a website using Delphi / Indy. Currently, I only have a button (used to send a password / username) that calls this procedure. procedure TForm5.Login(name: string; Pass: string); var UserID :string; Password :string; res : ...

Choose a group of radio buttons inside a container when a button is clicked

I have a bunch of containers containing radio buttons. The goal is for the container of a selected radio button to appear different: input[type="radio"]:checked+.container { border: 5px solid red; } <div class="container"> <input class="btn ...

position the tooltip within the ample available space of a container in an angular environment

In my editor, users can create a banner and freely drag elements within it. Each element has a tooltip that should appear on hover, positioned on the side of the element with the most space (top, left, bottom, right). The tooltip should never extend outsid ...

Tips for concealing the currently playing track title on a media player

I'm looking for a way to conceal the track title displayed in the media player on Internet Explorer. Here's the code I currently have: <object id="mediaPlayer" width="320" height="240" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type ...

Arrange the table by adding and editing before and after appending

I have a table data that needs to be dynamically appended. But I want to allow users to add new data using text input and also edit the existing data before and after it's appended. The problem is that when I append new data, it overwrites the previo ...

Enhancing Bootstrap project with personalized CSS styling

Utilizing SCSS to create my CSS has been the approach I've taken. The content of my main.scss file remains consistent even after it is compiled into css. .my-custom-row { background-color: bisque; } Contained within my index.html file is everythi ...

What advantages and disadvantages come with choosing between using vh and vw for responsive text?

My main inquiry is centered around the various techniques for creating responsive text. Is there a particular method that stands out as the best option for general use, or do different methods serve distinct purposes? ...

Separate your buttons with style using the Bootstrap button groups with

Is there a way to add border line separators between buttons in Bootstrap button groups? <div class="btn-group" role="group" aria-label="Button group with nested dropdown"> <button type="button" class=&quo ...

Error message "Jquery smooth scrolling issue: Unable to retrieve property 'top' as it is not defined"

I'm currently working on a script for a back to top button that will be placed in the footer of my website. However, I'm running into an issue where I'm getting an error message saying "Cannot read property 'top' of undefined". Any ...

Assistance with HTML and CSS to position an image in the corner

I need assistance with positioning a corner image on top of another image. I want the span, which has a small background image, to be in the top left corner of the main image. Below is my code: <div id="wrapkon"> <span style="width: 4px; height: ...

Add a decorative frame around the heading and text block

I'm looking to encase both the header and paragraph in a single border. Right now, they each have their own separate borders. How can I combine them into one? <style type="text/css> h1, p { font-family: consolas; border: 2px solid #73AD21; bor ...

Organizing textual maps within a 2D array for rendering on an HTML5 Canvas

In my spare time, I am working on creating an HTML5 RPG game. The map is implemented using a <canvas> element with specific dimensions (512px width, 352px height | 16 tiles across, 11 tiles from top to bottom), and I'm wondering if there's ...

The issue of HTML Service Submit Form not triggering the google.script.run function

Everything was going smoothly with my script until it suddenly stopped functioning properly. A user selects an option from a custom menu, triggering a dialog box (HTML Service form) to collect two parameters as intended. Upon submitting the form, the fol ...