I am dealing with too many unnecessary whitespaces on my website. Can someone advise me on how to rectify this

https://i.sstatic.net/1PoMd.png

My image should explain the issue, but I'll provide more details. Lately, as I build my webpage, I've noticed an excessive amount of whitespace on the right side that serves no purpose for me. Despite my efforts to adjust element widths in both my HTML and CSS files, the whitespace stubbornly remains. I'm seeking assistance to eliminate this unnecessary space. Here's a snippet of my HTML code:

   <!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">

        <!-- jQuery library -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

        <!-- Popper JS -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
        <link href='https://fonts.googleapis.com/css?family=Actor' rel='stylesheet'>
        <!-- Latest compiled JavaScript -->
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>


        <link rel="stylesheet" type="text/css" href="main.css">
        <title></title>
    </head>
    <body>
        <div class="container-fluid" style="font-family: Actor">
            <div class="row "  style="position: absolute; z-index: 999; opacity:1; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); background-color: #FFFFFF; padding: 4px;">
                <div class="col-xs-2">
                     <img src="images/1-OrderUp!!.jpg" alt="OrderUp logo">
                </div>
                <div class="col-xs-2">
                    <p class="text-style-1">OrderUp!!</p>
                </div>
                <div class="col-xs-1" style="height: 100px; background: #511F18; width: 2px; margin-left: 784px;"></div>
                <div class="col-xs-2">
                    <button class="btn btn-danger btn-lg" style="width: 100px">Log in
                        <?php

                        ?>
                    </button>
                </div>
                <div class="col-xs-1" style="height: 100px; background: #511F18; width: 2px;"></div>
                <div class="col-xs-2">
                    <button class="btn btn-danger btn-lg">Sign Up
                        <?php

                        ?>
                    </button>
                </div>
                 <div class="col-xs-1" style="height: 100px; background: #511F18; width: 2px;"></div>
            </div><br>
            <div class="row">
                <div class="col-xs-12" style="box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); width: 100%">
                    <div class="image">
                        <img src="images/home-1.jpg" style="width: 1350px;">
                        <p class="X">Welcome to OrderUp!!</p>
                        <p class="X_1"> Get food you love delivered at your doorstep!!</p>
                        <div >
                            <form class = "form-inline" class="srch_br"action="srch_location.php" method="post" enctype="multipart/form-data">
                                <input type="text" name="loc_srch" placeholder="Enter your location">
                                <button type="submit" class="btn btn-danger btn-md">Search</button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>

The CSS rules are as follows:

.btn.btn-danger.btn-lg{
    border-radius: 0;
    height: 100px;
}
.text-style-1{
    font-family:Actor;
    font-weight: bold;
    font-size:55px; 
    padding-top:2px; 
    padding-left:20px;  
    color: #511F18";
}
.image { 
   position: relative;
}

.X{ 
   position: absolute;
   top: 200px; 
   left: 820px; 
   width: 100%; 
   color: #FFFFFF;
   font-size: 55px;
}
.X_1{ 
   position: absolute; 
   top: 270px;
   left:660px;  
   width: 100%; 
   color: #FFFFFF;
   font-size: 35px;
}
.srch_br{
    position: absolute;
    top:400px;
    left: 50px;
    padding: 15px;
    background-color: #FFFFFF;
}

Answer №1

There are several issues that need to be addressed:

  • The classes X and X_1 for the popup are overlapping the viewport. Adjust the left value as a percentage.
  • An image is also exceeding the viewport boundaries. Set its width as a percentage.
  • Your fixed position div is overlapping as well. Define a suitable width for it.

.btn.btn-danger.btn-lg {
  border-radius: 0;
  height: 100px;
}

.text-style-1 {
  font-family: Actor;
  font-weight: bold;
  font-size: 55px;
  padding-top: 2px;
  padding-left: 20px;
  color: #511F18";

}

.image {
  position: relative;
  width: 100%;
}

.X {
  position: absolute;
  top: 200px;
  color: #FFFFFF;
  font-size: 55px;
}

.X_1 {
  position: absolute;
  top: 270px;
  color: #FFFFFF;
  font-size: 35px;
}

.srch_br {
  position: absolute;
  top: 400px;
  left: 50px;
  padding: 15px;
  background-color: #FFFFFF;
}
<div class="container-fluid" style="font-family: Actor">
  <div class="row " style="position: absolute; z-index: 999; opacity:1; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); background-color: #FFFFFF; padding: 4px;">
    <div class="col-xs-2">
      <img src="images/1-OrderUp!!.jpg" alt="OrderUp logo">
    </div>
    <div class="col-xs-2">
      <p class="text-style-1">OrderUp!!</p>
    </div>
    <div class="col-xs-1" style="height: 100px; background: #511F18; width: 2px; margin-left: 784px;"></div>
    <div class="col-xs-2">
      <button class="btn btn-danger btn-lg" style="width: 100px">Log in
                        <?php

                        ?>
                    </button>
    </div>
    <div class="col-xs-1" style="height: 100px; background: #511F18; width: 2px;"></div>
    <div class="col-xs-2">
      <button class="btn btn-danger btn-lg">Sign Up
                        <?php

                        ?>
                    </button>
    </div>
    <div class="col-xs-1" style="height: 100px; background: #511F18; width: 2px;"></div>
  </div><br>
  <div class="row">
    <div class="col-xs-12" style="box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); width: 100%">
      <div class="image">
        <img src="images/home-1.jpg" style="width: 1350px;">
        <p class="X">Welcome to OrderUp!!</p>
        <p class="X_1"> Get food you love delivered at your doorstep!!</p>
        <div>
          <form class="form-inline" class="srch_br" action="srch_location.php" method="post" enctype="multipart/form-data">
            <input type="text" name="loc_srch" placeholder="Enter your location">
            <button type="submit" class="btn btn-danger btn-md">Search</button>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>

Answer №2

The issue lies in these specific lines:

<p class="X">Welcome to OrderUp!!</p>
<p class="X_1"> Get food you love delivered at your doorstep!!</p>

The root of the problem is within the CSS code supplied.

Your original code:

 .X{ 
   position: absolute;
   top: 200px; 
   left: 820px; 
   width: 100%; 
   color: #FFFFFF;
   font-size: 55px;
}

.X_1{ 
   position: absolute; 
   top: 270px;
   left:660px;  
   width: 100%; 
   color: #FFFFFF;
   font-size: 35px;
}

The culprit lies with 'left: 820px' and 'left: 660px'

To resolve this, update them to zero:

.X {
    position: absolute;
    top: 200px;
    left: 0px;
    width: 100%;
    color: #FFFFFF;
    font-size: 55px;
}

.X_1 {
    position: absolute;
    top: 270px;
    left: 0px;
    width: 100%;
    color: #FFFFFF;
    font-size: 35px;
}

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

I am currently attempting to generate a chart that displays information on countries utilizing the restcountries API. Despite being a beginner in this area, I have encountered some challenges and am seeking guidance

I'm struggling to display detailed information for each country separately. Whenever I try to loop through the data, all the contents end up getting merged into a single cell. What can I do to achieve the desired result? https://i.stack.imgur.com/dZS ...

Explore various SVG paths by hovering to reveal or conceal different divs

Hi there, I'll do my best to explain clearly. If this question has already been asked, I apologize as I couldn't find an answer when searching. I've used SVG to create a map on my HTML webpage and it's looking great. I also have hidden ...

show small previews of pictures stored in a JavaScript array by using a for-loop

Currently stuck on a university project where I've set up an array of images like this: var testdata = [ { "imageID": 17, "uploadedDate": "2020-07-31 03:56:56.243139", "filepathOriginal": &qu ...

Creating uniform table column widths within a flex container with dynamic sizing

I am working on designing a navigation system for my website using a table inside a flexbox. I want to ensure that the table columns have equal width and can scale dynamically. Additionally, I aim to wrap the text in the data cells without changing the cel ...

Utilizing CSS to Create Fixed Position Elements

How can I create a CSS Style with a fixed position property for a div? When I place this particular div inside another div containing text, the fixed-positioned div overlaps the text, causing it to be hidden. I want to align the text and image divs next ...

Tips for changing the content of a td element to an input field and removing the displayed value

I am facing an issue with a dynamic table that displays names and input fields. When a name is displayed in a table row, the user has the option to delete that name. I am able to remove the value from a specific table row, but I am struggling to replace th ...

What is the method of adding a child to the outerHTML of the parent element instead of within it?

Is there a way to use the outerHTML method on a parent element to append a child element so that the icons appear outside of the targeted element rather than inside it? The current code snippet shows the icons inside the box, but I want them to be placed o ...

Unable to access all necessary files for app.scss within Laravel

While I am on the journey to master Laravel by following tutorials, I encountered an issue. After running npm install and then npm run dev, I noticed that my app.scss folder is empty and the variables.scss file is missing. I have been tirelessly searching ...

Enhance the "content switcher" code

I have been working on improving my "contenthandler" function. It currently changes different articles when I click different buttons, which I am satisfied with. However, I believe there may be a better approach to this and would appreciate any advice on h ...

Effortlessly adjust item width in CSS Grid

I am currently utilizing CSS Grid to showcase various tags. If a tag happens to be quite large, with a width exceeding 150px, I would ideally like that specific item to expand across multiple columns as necessary. For instance, in the visual representation ...

Setting the maximum width for a JavaScript pop-up box

Below is the html code that creates a link reading "sacola de compras" <div> <script type="text/javascript" src="https://app.ecwid.com/script.js?4549118"></script> <script type="text/javascript"> xMinicart("style=","layout=Mini") ...

Define the number of columns in CSS Grid and ensure that rows wrap accordingly

tag, I need to utilize CSS grid with 12 columns while ensuring that the tables stack in a column layout when the viewport size decreases. Is it possible to accomplish this using CSS grid? My research suggests that for row wrapping, I must use either ' ...

Store and retrieve intricate data structures using JSON serialization

Exploring the new local storage feature in HTML 5 has been quite fascinating. I've decided to utilize JSON for serializing and parsing my objects, which seems like a great idea. However, it's proving to be more challenging than anticipated. Simpl ...

Error message: "not properly formatted" encountered on Firefox browser, while Chrome browser reports the issue as "XMLHttpRequest.." error

Currently, I am delving into the world of three.js and have successfully converted an .obj file to a .js file for my object. I loaded this object using JSONLoader and was able to view it on Firefox browser. However, a JavaScript exception appeared in the c ...

How to retrieve a parameter from HTML using HttpServletRequest and getting a null value

Currently, I have a .jsp file running on a server, and my goal is to send user input form data to the "doPost" method in the HttpServlet. However, when I attempt to print the values of user input in doPost, they come out as null. I have been trying to re ...

Concealing a table row if a different row is devoid of content

In my table, I have dynamic rows that are either date rows or content rows. This allows me to display news items below the corresponding date row. <table class="channel-data"> <tbody> <?php $current_date = ""; while($programs=$ ...

Using CSS3 to layer two background images on the body element

Looking to create a unique design, I decided to use two images as a fixed background in CSS. Here is the code snippet I used: background: url(images/31.jpg) 100% no-repeat, url(images/12.jpg) 100% no-repeat; background-position: fixed; My goal is to make ...

Having trouble getting the JavaScript function to run when clicking a button inside a div or form?

Hey there, so I've got this scenario where I have a button nestled within a div. Take a look at the HTML snippet below: <div class="row"> <button type="button" id="submit">Send</button> </div> Prior to this button, there ...

jquery code to count the number of children in an html table

I'm struggling to grasp the behavior of the jquery method children. I can successfully count the number of <p> elements within a <div> using the following code: var abc = $("div").children("p"); alert(abc.length); However, when I a ...

Finding the Origin and Automatically Forwarding

I'm having an issue with my code. It's not functioning as expected. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml ...