Looking to attain the maximum width of the webpage

Seeking guidance as a newcomer to coding and HTML. Currently, struggling with achieving full width on the page for these HTML divs. The content is not displaying at full height and width as desired. Looking to adjust it to fit perfectly within the viewport and occupy the entire page. Any suggestions on how to accomplish this task effectively would be greatly appreciated.

Screenshot of the specific code:

Below is the HTML AND CSS code snippet provided for reference:

 (The CSS code block) 
  (The HTML code block) 

Answer №1

modify the width of the header, left, and footer to be 100%

setting the width in [px] indicates that it is a fixed value

 .header {
    width: 100%;
    height: 70px;
    background-color: red;
    border: 1px solid black;
    margin-bottom: 30px;
  }
  
  .footer {
    width: 100%;
    height: 50px;
    background-color: green;
    border: 1px solid black;
  }
  
  .left {
    width: 100%;
    height: 700px;
    display: block;
    background-color: black;
    border: 1px solid black;
    color: white;
    margin-right: 30px;
    display: flex;
    margin-bottom: 30px;
  }

Answer №2

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>


    <style>
        body {
  display: grid;
  margin: auto;
}

.header {
  width: 100%;
  height: 70px;
  background-color: red;
  border: 1px solid black;
  margin-bottom: 30px;
}

.footer {
  width: 100%;
  height: 50px;
  background-color: green;
  border: 1px solid black;
}

.left {
  width: 100%;
  height: 700px;
  display: block;
  background-color: black;
  border: 1px solid black;
  color: white;
  margin-right: 30px;
  display: flex;
  margin-bottom: 30px;
}

.right {
  width: 470px;
  height: 700px;
  background-color: green;
  border: 1px solid black;
}

.subleft {
  width: 300px;
  height: 300px;
  background-color: pink;
  border: 1px solid black;
  margin-left: 30px;
  margin-right: 500px;
  margin-top: 30px;
  display: flex;
}

.subright {
  width: 300px;
  height: 300px;
  background-color: rgb(163, 33, 54);
  border: 1px solid black;
  margin-left: 30px;
  margin-top: 30px;
  display: block;
}

html {
  height: 100%;
}

.insidesubtopexaxt {
  width: 240px;
  height: 70px;
  background-color: rgb(192, 207, 255);
  border: 1px solid black;
  margin-left: 30px;
  margin-top: 30px;
  margin-bottom: 100px;
}

.insidesubbottomexaxt {
  width: 240px;
  height: 70px;
  background-color: pink;
  border: 1px solid black;
  margin-left: 30px;
  margin-bottom: 30px;
  margin-right: 30px;
}

.insidesubleft {
  width: 300px;
  height: 100px;
  background-color: rgb(0, 195, 255);
  text-align: center;
  margin-left: 30px;
  margin-top: 30px;
}

.equalmargindiv {
  padding: 20px;
  width: 10px;
  height: 10px;
  background-color: brown;
  border: rgb(7, 7, 7) 1px solid;
  margin-left: 25px;
  margin-top: 25px;
  margin-bottom: 25px;
  margin-right: 25px;
}

.insidesubright {
  width: 300px;
  height: 100px;
  background-color: orange;
  text-align: center;
  margin-right: 30px;
  margin-left: 30px;
  margin-top: 30px;
}
    </style>
</head>

<body>
    <div class="header">Hello, Header</div>
<div class="wrapper">

  <div class="left">

    <div class="subleft">


      <div class="insidesubleft">

        <div class="equalmargindiv">

        </div>


      </div>
      <div class="insidesubright">


      </div>
    </div>

    <div class="subright">

      <div class="insidesubtopexaxt">

      </div>
      <div class="insidesubbottomexaxt">


      </div>
    </div>


  </div>
  <div class="footer">Footer</div>
</body>
</html>

Answer №3

Consider utilizing the "viewport width" technique as a potential solution

.navigation {
  width: 100vw;
  height: 50px;
  background-color: blue;
  border: 1px solid gray;
  margin-bottom: 20px;
}

Answer №4

The reason for the issue is that a fixed width of 1200px has been set for the classes .header, .footer, and .left. To make them full width, simply change the width to 100% or 100vh. If a specific width is set, the element's width will not adjust accordingly.

body {
  display: grid;
  margin: auto;
}

.header {
  width: 100%;
  height: 70px;
  background-color: red;
  border: 1px solid black;
  margin-bottom: 30px;
}

.footer {
  width: 100%;
  height: 50px;
  background-color: green;
  border: 1px solid black;
}

.left {
  width: 100%;
  height: 700px;
  display: block;
  background-color: black;
  border: 1px solid black;
  color: white;
  margin-right: 30px;
  display: flex;
  margin-bottom: 30px;
}

.right {
  width: 470px;
  height: 700px;
  background-color: green;
  border: 1px solid black;
}

.subleft {
  width: 300px;
  height: 300px;
  background-color: pink;
  border: 1px solid black;
  margin-left: 30px;
  margin-right: 500px;
  margin-top: 30px;
  display: flex;
}

.subright {
  width: 300px;
  height: 300px;
  background-color: rgb(163, 33, 54);
  border: 1px solid black;
  margin-left: 30px;
  margin-top: 30px;
  display: block;
}

html {
  height: 100%;
}

.insidesubtopexaxt {
  width: 240px;
  height: 70px;
  background-color: rgb(192, 207, 255);
  border: 1px solid black;
  margin-left: 30px;
  margin-top: 30px;
  margin-bottom: 100px;
}

.insidesubbottomexaxt {
  width: 240px;
  height: 70px;
  background-color: pink;
  border: 1px solid black;
  margin-left: 30px;
  margin-bottom: 30px;
  margin-right: 30px;
}

.insidesubleft {
  width: 300px;
  height: 100px;
  background-color: rgb(0, 195, 255);
  text-align: center;
  margin-left: 30px;
  margin-top: 30px;
}

.equalmargindiv {
  padding: 20px;
  width: 10px;
  height: 10px;
  background-color: brown;
  border: rgb(7, 7, 7) 1px solid;
  margin-left: 25px;
  margin-top: 25px;
  margin-bottom: 25px;
  margin-right: 25px;
}

.insidesubright {
  width: 300px;
  height: 100px;
  background-color: orange;
  text-align: center;
  margin-right: 30px;
  margin-left: 30px;
  margin-top: 30px;
}
<div class="header">Hello, Header</div>
<div class="wrapper">

  <div class="left">

    <div class="subleft">


      <div class="insidesubleft">

        <div class="equalmargindiv">

        </div>


      </div>
      <div class="insidesubright">


      </div>
    </div>

    <div class="subright">

      <div class="insidesubtopexaxt">

      </div>
      <div class="insidesubbottomexaxt">


      </div>
    </div>


  </div>
  <div class="footer">Footer</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

HowlerJS: Unauthorized Access - Error Code 401

Working with Angular 7, I have developed an application that consumes data from an API. I have successfully implemented CRUD functionalities using an http-interceptor that adds a token to each request. However, I encountered a 401 error when integrating Ho ...

Issue with OBJLoader showing a blank screen

Does anyone have experience with rendering OBJ files using three.js? I'm having trouble getting them to display on the screen and would appreciate any help or advice. The strange thing is that a simple cube renders perfectly in my project. For those ...

Height problem with the data-reactroot component

On one of my web pages, there is a data-reactroot element with a height of approximately 1906px. However, the surrounding divs and html tags have a height of only 915px. I am trying to figure out how to make all the enclosing elements match the same heigh ...

Attempting to attach a group of HTML elements to a specific div element on a web page using jQuery, however, the elements are not appearing as expected

I can't seem to get an array of HTML elements added to a div element on my page. Even though the console.log shows that the array is successfully added to the div element, it still doesn't display on the page. Here's the code I'm workin ...

What is the best way to dynamically duplicate the Bootstrap multi-select feature?

$(function() { $('#days').multiselect({ includeSelectAllOption: true }); $('#btnSelected').click(function() { var selected = $("#days option:selected"); var message = ""; selected.each(function() { message ...

I'm attempting to access CapCut through the site with Selenium, but I'm having trouble clicking on a specific button

My goal is to click on a specific button with the following code: <button class="lv-btn lv-btn-primary lv-btn-size-default lv-btn-shape-square lv_sign_in_panel_wide-primary-button" type="button"><span>Continue</span>&l ...

Adapting content based on various media queries

After spending more time on this question, I hope to clarify my thoughts better this time around. I am currently designing a responsive layout for my upcoming landing page. The main header in the body changes based on the browser size and device. <h1& ...

Does the get_text() function in bs4 behave differently when used with span tags? I'm unable to remove the

As I develop a web scraper, I can successfully locate and extract data from two fields. Using BeautifulSoup's get_text() function helps me remove HTML tags from the data in these fields. However, I encounter an issue with the third field when attempt ...

What's the best way to make sure an image and text are perfectly aligned on the

How can I align an image and text on the same line, as currently the a tag is higher than my text? Here is the HTML code: <div class="author-name"> <img class="article-author-img" src="{{ preload(asset('assets/st ...

Customizing Checkbox Properties in Google Web Toolkit

When working with a UiBinder, I have created a checkbox element using the following code: <g:CheckBox ui:field="ignoreCase"/> To set the text in the java code, I am using this method: ignoreCase.setText(UIConverter.getUILocalization().get(UINames. ...

Remove each dropdownlist individually as they are added

Is there a way to remove dropdownlists one by one? I am using jQuery to dynamically create and append dropdownlists with buttons in a div. The buttons are used to delete the corresponding dropdownlist. Requirement: Ability to delete dropdownlists one b ...

Issue with scroll down button functionality not functioning as expected

Is there a way to create a simple scroll down button that smoothly takes you to a specific section on the page? I've tried numerous buttons, jQuery, and JavaScript methods, but for some reason, it's not working as expected. The link is set up co ...

Conceal table columns on an HTML page using CSS styling

HTML: <table class="list qy"> <tr> <td>cell1</td> <td class="q">cell2</td> <td>cell3</td> <td class="y">cell4</td> </tr> </table> CSS: table.qy td.q, table.qy td.y { displ ...

My mobile is the only device experiencing responsiveness issues

One challenge I'm facing is with the responsiveness of my React application, specifically on my Galaxy J7 Pro phone which has a resolution of 510 pixels wide. Interestingly, the app works perfectly on a browser at this width, as well as on my tablet ...

Updating a div's border using JavaScript

I recently generated a div element dynamically through code. var Element; Element = document.createElement('div'); My goal now is to modify the right and bottom borders to "#CCCCCC 1px solid". I aim to achieve this without relying on any exte ...

JavaScript multi-layered structures

I am in need of assistance creating JavaScript objects and arrays to meet the following requirements. Can anyone provide me with a sample? Requirements Begin with invoice numbers. Key: invoice, Value: INV001, INV002, INV003... Each invoice number contai ...

What is the method to alter the fill of a circle using CSS when it is hovered over in JavaFX?

I am seeking assistance for a task involving a circle within an hBox. I would like the color of the circle to change when the mouse cursor hovers over it. Is there a way to accomplish this using JavaFX and CSS? If not, what is the recommended approach fo ...

Unique Font Awesome Stylesheets

I'm facing a challenge with using Font Awesome to design my form. The FA icon comes pre-filled with color, but when I try to apply a specific color, it gets applied to the entire icon. Is there a way to work around this issue? Alternatively, should I ...

Having issues with the background image on the homepage not displaying correctly?

Having trouble with the background image not displaying correctly even when set to 100%? https://i.sstatic.net/eavwX.png I'm currently using Angular and Bootstrap 4 for this project. <!--html code--> <div class="bg"> <div style="text ...

Prevent lengthy headers from disrupting the flow of the list items

I've encountered an issue while working on a website that features a list of items. When the title, such as "roller blinds," spans across two lines, it disrupts the layout below. How can I prevent this from happening without compromising on having lon ...