The Overflow-x in CSS and AngularJS

I could use some assistance with css. When adding another hexagon on the right side, it currently jumps down to create a new row rather than overflowing horizontally. How can I make it overflow with a horizontal scroll instead?

Below is the css code:

#flow {
    width: 600px;
    height: 250px;
    overflow-x: scroll;
}

Answer №1

While not the most refined solution, this method gets the job done. http://jsfiddle.net/L6pke/5/

#container {
    width: 500px;
    height: 250px;
    overflow-x: auto;
}
#flow {
    width: 800px;
    height:100%;
}

In your JavaScript code, make sure to adjust the width of the flow div each time you add an element.

var flow = document.getElementById('flow'),
           current_width = flow.clientWidth;
flow.style.width = current_width + 104 + 'px';

Answer №2

Give this a shot:

#flow {
    width: 550px;
    height: 250px;
    overflow-x: scroll;
}

.hex {
    display: inline-block;
    margin-left:3px;
    margin-bottom:-26px;
    text-align:center;
    color:#fff;
    font-size:1.1rem
}

.hex-row {
    clear:left;
    white-space: nowrap;
}

In essence:

Change the display of .hex to inline-block, which is more efficient than floating in this case. Floating would not work due to its impact on the normal flow.

Eliminate the width property in .hex-row to allow automatic sizing, and apply white-space: nowrap to prevent wrapping.

http://jsfiddle.net/zargyle/L6pke/3/

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

Angular2 data binding does not update when properties change

I'm struggling to establish the connection between the fields and the component in order for them to update when the properties change in OnDataUpdate(). The field "OtherValue" successfully binds two ways with the input field, and the "Name" field di ...

The animation on my jQuery script seems to be malfunctioning

I'm encountering an issue with a div element that is partially off the screen and should move out when a button is clicked. I've shared my script here, but it seems to not work as intended when the button is pressed. The visualization in jsfiddle ...

Attempting to alter the background image through the action of clicking on an image using jQuery, HTML, and CSS

I have created custom weather icons like a sun, cloud, and rainy cloud using Photoshop. My goal is to allow users to click on these icons and change the background image of the website's body. However, despite my efforts, clicking on the images does n ...

Transferring various sets of information into a single array

In an attempt to generate JSON data in an array for passing to another component, I followed a method outlined below. However, being relatively new to this field, my execution may not have been optimal as expected. employeeMoney: any[] = []; employeeId: an ...

Subfolder complications arise when trying to implement AngularJS with Apache rewrite rules

Incorporating AngularJs with html5mode enabled requires the use of a rewrite in the .htaccess file to specify the folder path. While navigation to the main index page functions correctly, encountering errors arises when trying to access subfolders such as ...

Dynamic Bootstrap Table with Fixed Header

I am customizing a Bootstrap table by adding CSS for a sticky header. My code snippet includes the following: .table-sticky th { background: #fff; position: sticky; top: -1px; z-index: 990; } <div class ...

Issue with retrieving data from dataTransfer on 'drop' event due to undefined value

I'm currently working on implementing Drag & Drop functionality using AngularJS directives. Here's the concept I am trying to execute : Check out my codePen However, I keep encountering an error saying 'getData' is undefined. Th ...

What steps can be taken to activate the remember password feature when using an AJAX login system?

I've developed a web application with a basic login box, utilizing jQuery AJAX for the login process. However, I'm facing an issue with prompting the browser to remember the password. How can I trigger the "Do you want the browser to remember th ...

Arranging an image next to a text input in Bootstrap 5: A step-by-step guide

I want to align a magnifying glass image next to a text input on the left side. However, it is currently displaying above the text input. How can I make sure they are positioned side-by-side using Bootstrap 5? <link rel="stylesheet" href="https://c ...

I am having trouble getting my console.log function to work properly on my HTML page

As a beginner in JavaScript, I am facing an issue with my console.log not working at all. When I type a console.log message, nothing shows up on my HTML page. I have tried to debug it, but being a newbie, I lack the necessary knowledge. All I can do is see ...

The dropdown menu is extending beyond the bounds of the screen on mobile devices

When viewing my website on a mobile device, the select dropdown is going off the screen. I am using the bootstrap class form-control. Here is my code: <select name="service" formControlName="service" class="form-control shadow-none" style="width:100%"& ...

Utilizing AngularJS Factory to Share Data Among Controllers

Following a tutorial on YouTube for Sharing Data between Controllers, I am facing an issue where the two inputs do not return shared data that is bind-able. Can someone please help me identify what might be wrong in my code? <!DOCTYPE html> ...

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 ...

What are some ways I can showcase the outcomes of my multiple choice quiz?

I need help with my multiple choice quiz. I want to display the answers under each question and highlight the correct one in bold. Here is the current code: function check() { var question1 = document.quiz.question1.value; var question2 = document.q ...

Adjusting the angular routerLink based on an observable

When working with HTML in Angular, I am looking for a way to use an <a> tag that adjusts its routerlink based on whether or not a user is logged in. Is it possible to achieve this functionality within a single tag? <a *ngIf="!(accountService ...

What is the process for bringing an array from a .js file into an HTML document?

Exploring the world of JS and HTML, I recently came across an assignment that involved working with a file named stocks.js, which houses an array of stock information: 'use strict'; const stocks = [ { company: 'Splunk', symbol: &ap ...

Looking for assistance in determining a solution for progress bar implementation

Currently, I am developing a simple application using web technologies like HTML, CSS, and jQuery Mobile. This app enables me to create goals and save them to a listview using the <li> element. Every <li> representing a goal will have an assoc ...

Having trouble accessing an element using jQuery(idOfElement) with a variable as the name parameter

Possible Duplicate: Issue with JavaScript accessing JSF component using ID Whenever I attempt to retrieve an element by passing a variable in jQuery(idOfElement), it doesn't work. But if I use something like jQuery('#e'), it works perfe ...

Adding data to MySQL database utilizing jQuery and PHP

I'm facing an issue that I can't seem to figure out. The code is not throwing any PHP errors, so I suspect it might be a client-side problem, although I could be mistaken. The objective is to have a form submit the content of a text field to a M ...

The inner div overflowing at 100% dimensions

I'm working with an outer DIV that has a CSS property of position: fixed to serve as an overlay. Inside this, I have another div set to 100% width with a margin of 30px to create the appearance of an inner border frame. Unfortunately, the right and bo ...