Are your divs getting truncated?

Currently faced with a perplexing issue where inserting elements into a div causes scaling problems, resulting in most of the divs being cut off. This glitch occurs when two new elements are added.

Despite changing page sizes and thoroughly debugging by outputting various prints to isolate the cause, I'm unable to comprehend why this functionality suddenly fails?

View without 4 new elements: https://i.sstatic.net/6BpIu.png

View with 4 new elements: https://i.sstatic.net/IhOTz.png

JSON Structure:

            var Product = {
                Name: Name,
                BuyPrice: BuyPrice,
                SellPrice: SellPrice,
                ProfitMargin: ProfitMargin,
                Demand: Demand,
                Volume: Inflation,
            }

Javascript Code:

            var Product = ProfitDescending[i]

            var Product = ProfitDescending[i]
            var Div = document.createElement("div")
            Div.id = Product.Name
            Div.className = "Product"
            document.getElementById("Products").appendChild(Div)

            var NameText = document.createElement("h1")
            NameText.id = "NameText"
            NameText.textContent = FixName(Product.Name)
            document.getElementById(Product.Name).appendChild(NameText)

            var ProfitMarginText = document.createElement("p")
            ProfitMarginText.id = "ProfitText"
            ProfitMarginText.textContent = "Profit: " + AbbreviateNumber(parseInt(Product.ProfitMargin),1)
            document.getElementById(Product.Name).appendChild(ProfitMarginText)

            var BuyPriceText = document.createElement("p")
            BuyPriceText.id = "BuyPriceText"
            BuyPriceText.textContent = "Buy Price: " + AbbreviateNumber(parseInt(Product.BuyPrice),1)
            document.getElementById(Product.Name).appendChild(BuyPriceText)

            var SellPriceText = document.createElement("p")
            SellPriceText.id = "SellPriceText"
            SellPriceText.textContent = "Sell Price: " + AbbreviateNumber(parseInt(Product.SellPrice),1)
            document.getElementById(Product.Name).appendChild(SellPriceText)

            //Adding 4 new elements below (Previous part functions fine)

            var DemandTitleText = document.createElement("h1")
            DemandTitleText.id = "DemandTitleText"
            DemandTitleText.textContent = "Demand:"
            document.getElementById(Product.Name).appendChild(DemandTitleText)

            var DemandText = document.createElement("p")
            DemandText.id = "DemandText"
            DemandText.textContent = Product.Demand
            DemandText.style.color = Colors[Product.Demand][0]
            document.getElementById(Product.Name).appendChild(DemandText)

            var VolumeTitleText = document.createElement("h1")
            VolumeTitleText.id = "VolumeTitleText"
            VolumeTitleText.textContent = "Volume:"
            document.getElementById(Product.Name).appendChild(VolumeTitleText)

            var VolumeText = document.createElement("p")
            VolumeText.id = "VolumeText"
            VolumeText.textContent = Product.Demand
            VolumeText.style.color = Colors[Product.Volume][0]
            document.getElementById(Product.Name).appendChild(VolumeText)

CSS Style:

body {
    background-color: rgb(40, 40, 40);
    overflow-x: hidden;
    height: 20000px;
}

#Logo {
    width: 250px;
    position: absolute;
    left: 10px;
    top: 10px;
    z-index: 1;
}

#AngledDiv {
    position: absolute;
    width: 120%;
    left: -50px;
    top: -50px;
    height: 620px;
    transform: rotate(-2deg);
    background-color: rgb(50, 50, 50);
}

#Products {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-gap: 10px;
    overflow: hidden;
    position: absolute;
    width: 1200px;
    height: 20000px;
    top: 430px;
    left: 50%;
    margin-left: -600px;
}

.Product {
    background-color: rgb(60, 60, 60);
    border-radius: 5px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05)!important;
}

#NameText {
    position: relative;
    font-weight: 600;
    top: -15px;
    left: 10px;
    font-family: Montserrat,system-ui;
    font-size: 26px;
    color: #FFAA00;
}

#ProfitText {
    position: relative;
    margin-top: -15px;
    left: 10px;
    font-family: Montserrat,system-ui;
    font-weight: 450;
    font-size: 24px;
    color: white;
}

#BuyPriceText {
    position: relative;
    margin-top: -20px;
    left: 10px;
    font-family: Montserrat,system-ui;
    font-weight: 450;
    font-size: 24px;
    color: rgb(180, 180, 180);
}

#SellPriceText {
    position: relative;
    margin-top: -28px;
    left: 10px;
    font-family: Montserrat,system-ui;
    font-weight: 450;
    font-size: 24px;
    color: rgb(180, 180, 180);
}

#DemandTitleText {
    position: relative;
    font-weight: 350;
    top: -15px;
    left: 10px;
    font-family: Montserrat,system-ui;
    font-size: 26px;
    color: white;
}

#DemandText {
    position: relative;
    font-weight: 350;
    top: -74px;
    left: 118px;
    font-family: Montserrat,system-ui;
    font-size: 26px;
    color: white;
}

Answer №1

It dawned on me that I had been neglecting margins, but once I added a margin-top, all of my problems were solved.

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

"Is there a way to retrieve the CSS of all elements on a webpage by providing a URL using

Currently, I am in the process of creating a script that can crawl through all links provided with a site's URL and verify if the font used on each page is helvetica. Below is the code snippet I have put together (partially obtained online). var requ ...

Which is more efficient: filtering a JSON object or querying the database using ajax?

I am currently developing a product page that involves a selection of options that will impact the pricing of the items. The primary option allows users to choose a material, which then influences the available set of options. Within the database, there i ...

Issue with Angular $compile directive failing to update DOM element

I'm currently working on a project that involves integrating AngularJS and D3 to create an application where users can draw, drag, and resize shapes. I've been trying to use angular binding to update the attributes and avoid manual DOM updates, b ...

Is your form complete?

Is there a way to determine if all required fields in the current form are correctly filled in order to disable/enable navigation? Are there any specific properties or JQuery functions that can be used to check for form completion status? ...

Troubleshooting issue with the JQuery .change function not working in HTML <select>

I can't figure out why this code isn't working. It seems like it should be simple enough. Take a look at my drop-down menu code: <div> <form> <select id='yearDropdown'> <c:forEach var="year ...

Refreshing the page resolves unhandled errors that occur when an item is removed from local storage

I'm currently working on adding a logout button to my website. I have the user's token saved in local storage, but when the logout button is clicked and the token is removed from local storage, an error occurs upon redirecting back to the login p ...

Creating a JavaScript function using jQuery to calculate the total sum of textboxes with two specified classes

I'm currently attempting to calculate the total of a group of textboxes by utilizing jquery. Each textbox is styled with a class (class1) using bootstrap. To execute the jquery function, I've added an extra class (class2). Below is an example of ...

A TypeScript example showcasing a nested for-of loop within several other for loops

Is it possible to generate values from an Array of objects in the following way? const arr = [ { type: "color", values: [ { name: "Color", option: "Black", }, { name: "C ...

I can't get Toggleclass to switch classes properly, am I missing something?

I have been experimenting with creating a button that toggles a class and reveals another div below it. Feel free to check out the example on jsFiddle that I created for you. While the first function of showing and hiding the div is working perfectly, I ...

Tips for resolving the error "Cannot access the title property of undefined" when utilizing NextJS prerendering

I am preparing this page in advance for a specific post within my Next.js application: import Head from 'next/head'; import Link from 'next/link'; import client from '../../lib/apollo/client' import POSTS_WITH_SLUGS from &apos ...

Revamp State before redirecting using React Router Dom

In my current project, I am facing an issue with redirecting after updating the state successfully. The technologies I'm using include React 16.12.0 and React Router DOM 5.1.2. Here's the scenario: I have a button that, when clicked, should updat ...

How can I execute JavaScript within a for loop in the server-side code?

protected void Button1_Click(object sender, EventArgs e) { for (int i = 0; i < 100; i++) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "myScript", "<script>alert('hello world');</script>"); } } Is th ...

What steps can I take to resolve this issue when encountering an error during npm install?

As a newcomer to programming, I am embarking on the creation of a Discord bot using node and discord.js. My current hurdle involves the installation of a library named canvas, which seems to be causing issues. After developing and testing my application o ...

Why do HTML elements in an email have strange prefixes added to their IDs?

Currently, I am working on setting up automated tests for my service that automatically sends email reports. The objective is to verify the accuracy of data in the emails. To accomplish this, I have started assigning unique IDs to different HTML elements ...

Headers and data organization in Angular 2

I'm searching for a simple Angular 2 example that demonstrates how to fetch both the headers and data from a JSON API feed. While there are plenty of examples available for fetching data only, I haven't been able to find any that show how to retr ...

'jQuery' is not recognized as defined, error no-undef

I am currently working on a file that utilizes jQuery for testing purposes: (function($) { "use strict"; // Start of use strict // Configure tooltips for collapsed side navigation $('.navbar-sidenav [data-toggle="tooltip"]').tooltip({ ...

Conceal the scrollbar track while displaying the scrollbar thumb

Hey there! I'm looking to customize my scroll bar to have a hidden track like this. Everyone's got their own style, right? ::-webkit-scrollbar{ width: 15px; height: 40px; } ::-webkit-scrollbar-thumb{ background-color: #DBDBDB; borde ...

Is it possible to modify a website's CSS permanently using just the browser?

Is there a way to make changes to CSS in a large project using Firefox's built-in developer tools and have them saved permanently? I've been trying to edit the style sheets, but couldn't locate the specific property I needed. Since I can&apo ...

Transform a Django/Python dictionary into a JavaScript dictionary using JSON

I need to convert a Python dictionary into a JavaScript dictionary. From what I understand, I have to first convert the Python dict into JSON format and then transform it into a JavaScript Object. view.py jsonheaderdict = json.dumps(headerdict) {{jsonhe ...

"Enhance Your Phonegap Android App with Pinch Zoom Capability

I am currently working on an Android Application with the help of jQuery Mobile and Phonegap. My goal is to implement pinch zoom functionality on the App pages. I have come across several suggestions that involve using the following line, but unfortunatel ...