Issue with div element not stretching to 100% width

I am currently working on a fluid layout design where the template includes a header, menu, and body section.

<div  class="w100 h100">
    <div id="headerBox" style="height: 10%;" class="w100">
        <div style="width: 80%;" class="lfloat">
            <tiles:insertAttribute name="header" />
        </div>
        <div style="width: 18%; height: 80%;" class="lfloat">
            <tiles:insertAttribute name="menu" />
        </div>
    </div>
    ---------------body container here --------------
</div>

css

.h100{
    height:100%;
}
.w100{
    width: 100%;
}
html {
    height: 100%;
    width: 100%;
}
body {
    font-family: "Times New Roman", Times, serif;
    width: 100%;
    height: 100%;
    margin: 0%;
    padding: 0%;
    overflow: auto;
}

Currently, I am facing an issue where setting the child div's (menu) width to 20% causes my HTML page to display a horizontal scroll bar. Even though the parent div's width is set to 100%, the child div does not scale up to 100%. In order to prevent this issue, I have resorted to setting the child div's width to 18%. What could be causing this problem?

Answer №1

Include the following CSS in your div elements

.block {
  display: inline-block;
  vertical-align: top;
  -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
  -moz-box-sizing: border-box;    /* Firefox, other Gecko */
  box-sizing: border-box;
}

---------------html --------------
<div class="w100 h100 block">
    <div id="headerBox" style="height: 10%;" class="w100 block">
        <div style="width: 80%;" class="lfloat block">
            <tiles:insertAttribute name="header" />
        </div>
        <div style="width: 18%; height: 80%;" class="lfloat block">
            <tiles:insertAttribute name="menu" />
        </div>
    </div>
    ---------------body container here--------------
</div>

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

Error: Undefined variable in JavaScript obfuscation

My website has several small JavaScript files that I currently merge into one file and then minimize using terser. The website functions perfectly with the minimized version. Now, I want to take it a step further and obfuscate the code using JavaScript-Ob ...

Can you modify the current HTML code of a Wix website?

I am currently developing a website using Wix and have encountered an issue with the page description. Despite editing it in Wix, the changes are not reflecting on the live site. Upon inspecting the source code in Chrome, I identified the problem lies wi ...

Encountering a problem with npm installation during the setup of node-sass

While attempting to run the npm install command, I encountered an error during the installation of node-sass. https://i.stack.imgur.com/qcDaA.png https://i.stack.imgur.com/YxDi2.png Here is my package.json file: { "name": "XXXXX", ...

Top method for establishing a mysql connection in Express version 4

Recently, I installed node-mysql and started running on express 4. Although I'm new to express, I am eager to learn the best practices for handling database connections. In my current setup, I have app.js var mysql = require('mysql'); //se ...

Redirecting to a separate component outside the current structure and transferring a callback function

How can I navigate from App.js, the default component, to a new component that is not within the hierarchy while passing a function? I have three components: Question for displaying questions, Upvote for upvoting, and Downvote for downvoting. Here is the ...

I can't seem to figure out why my container is not centered on the screen, despite setting the margins (left and right) to auto

Hey there, I'm a beginner in programming and currently experimenting with the CSS vertical text slide animator feature. However, when the animation runs smoothly, I noticed that the text appears disproportionate and not properly centered on the screen ...

Exploring Opencascade.js: Uncovering the Real Text within a TCollection_ExtendedString

I am currently attempting to retrieve the name of an assembly part that I have extracted from a .step file. My method is inspired by a blog post found at , however, I am implementing it using javascript. I have managed to extract the TDataStd_Name attribut ...

Oops! An error occurred: Uncaught promise rejection - invalid link found for ProductListComponent

I am currently in the process of learning Angular and Ionic, but I am feeling a bit confused as to where my mistake is. I have looked at other questions, but I still can't seem to figure it out. Can anyone provide some assistance? Perhaps someone has ...

Determining the page's coordinates in ColdFusion

Whenever I use iframes or frames on older websites, I implement an additional security measure using a JavaScript function: <SCRIPT LANGUAGE="JavaScript1.1"> if (top == self) self.location.href = "../index.cfm"; </SCRIPT> I also include an ...

Visual Studio Code version 1.42 is now automatically converting <br> tags to <br /> when formatting code

This issue just started occurring. I'm not exactly sure what triggered it, but it could be related to my attempt to activate the Preitter extension. As a newcomer to Visual Studio Code, I am currently working on HTML5 documents. Strangely, whenever I ...

Combine iron-page and bind them together

Recently, I've started learning about Polymer and I want to bind together paper-tabs and iron-pages so that when a tab is clicked, the content loads dynamically. After going through the documentation, this is what I have tried: <app-toolbar> ...

Enter your search term and display the results instantly without the need to refresh the page

After entering a query into the input box and hitting submit, the system currently checks the database for results, refreshes the page, and then displays the matching records. Is there a method to prevent the automatic page refresh when displaying the sea ...

Tips for locating a file using javascript

My application scans a folder and displays all folders and HTML files inside it in a dropdown menu. It also shows any HTML files inside an iframe. There is one file named "highlighted.html" that should not appear in the dropdown menu, but if it exists in t ...

Highcharts 3D Pie Chart with Drilldown Feature

How can I create a 3D Pie Chart with Drilldown effect? I am having trouble understanding how it works. Here is a JsFiddle Demo for a 3D Pie Chart: JsFiddle Demo And here is a JsFiddle Demo for a 2D Pie Chart with Drilldown feature: JsFiddle Demo You can ...

Looping through Angular promises sequentially

I am faced with a dataset consisting of the following information. $scope.orders = [ { material: 'A', quantity: 32, orderNumber: 'dummy'}, { material: 'A', quantity: 65, orderNumber: 'dummy'}, ...

Getting HTML from Next.js middleware - a step-by-step guide

Is there a way to send the HTTP Status Code 410 (gone) together with a customized HTML message? I want to display the following content: <h1>Error 410</h1> <h2>Permanently deleted or Gone</h2> <p>This page is not foun ...

Set the error state of a TextField in Material UI to true based on the user's input

Being a newcomer to React and Javascript, I have made some progress but now find myself stuck. I am struggling with how to change the error state of a Material UI TextField based on user input. Specifically, I want the error to be triggered if the user inp ...

What is the best method for adding space between elements in flexbox layout?

I am struggling to align the child flexboxes within my parent flexbox in a single row, both vertically and horizontally centered. I want to add space between them using the gap property in CSS, but the images and embedded videos inside these child flexboxe ...

An effective approach to positioning HTML elements at specific X and Y coordinates

I have an innovative project idea! The concept is to enable users to create points by clicking on the display. They can then connect these points by clicking again. However, I am facing a challenge when it comes to creating HTML elements at the exact loc ...

The jQuery AJAX variable was successfully sent via a POST request, but unfortunately, I am unable to access it in PHP

Objective: The goal is to trigger a jQuery AJAX request when clicking on a table cell (td). This request will send the corresponding reservationid via a POST method to the same page containing the clicked td. In the PHP file, a query will be executed to f ...