I'm still trying to figure out the property position. Why won't my page scroll? (My first time using HTML)

I'm having an issue with my webpage where it doesn't scroll even when the content exceeds the page length.

I've tried adjusting the position settings for the body, html, and div elements but haven't seen any changes.

Here is the HTML code snippet:

html {
  position: absolute;
  overflow-y: scroll;
}

body {
  background-color: dimgray !important;
}

body div {
  position: absolute;
}

header {
  position: fixed;
  padding: 10px 0;
  background-color: dimgray;
  border-bottom: 1px solid black;
}
<header class="container-fluid">
  <div class="row">
    <div class="col-sm-4"><img src="/Fedecocagua.png"></div>
    <div class="col-sm-8">
      <ul class="nav">
        <li class="nav-item">
          <a class="nav-link" href="Pruebah2.html" target="_blank" style="color: black">¿Quiénes somos?</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#bottom" style="color: black">Contáctanos</a>
        </li>
      </ul>
    </div>
  </div>
</header>

Answer №1

If you set your html and body to have a position:absolute, it will prevent the page from scrolling. To fix this issue, remove the declaration as shown below:

body {
    background-color: dimgray !important;
}

header {
    position:fixed;
    padding: 10px 0;
    background-color: dimgray;
    border-bottom: 1px solid black;
}

An element with position:absolute is taken out of the document flow, allowing it to be any size and always placed outside the document. Your html and body are special in this regard; there are limited scenarios where positioning them absolutely is necessary. Instead of worrying about their position, focus on creating content within div elements which will naturally scroll when exceeding the page height, like demonstrated here:

div {
    margin-bottom:50px;
}
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut porta nisi libero, id porta lacus rhoncus id. Pellentesque rutrum molestie maximus. In eu risus id magna tincidunt commodo placerat nec quam. Sed suscipit magna risus, quis rutrum nisl fringilla eget. Ut malesuada consequat quam, non mattis odio viverra blandit. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam ultrices nibh et congue sodales. Phasellus sem urna, aliquam id tristique non, lacinia a libero. Vivamus ac elit ligula. Phasellus et nulla viverra, ultrices nibh id, euismod quam. Sed aliquet scelerisque elit, id sodales augue.
</div>
<div>
Maecenas quis luctus odio. Vivamus in libero ligula. Proin viverra consectetur sagittis. Interdum et malesuada fames ac ante ipsum primis in faucibus. In rutrum ligula vitae sodales tincidunt. Etiam semper, libero sed pulvinar rhoncus, justo turpis lobortis elit, vitae dapibus magna massa a dolor. Sed tempor tortor id velit sollicitudin vestibulum. Integer ac felis orci. Etiam metus felis, porta at lectus eu, aliquet pharetra tortor. Curabitur varius tortor vitae tellus suscipit pharetra. Maecenas sit amet tortor ornare, viverra augue vitae, aliquet felis. Integer accumsan dolor ac imperdiet dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Pellentesque lobortis non quam quis semper.
</div>
<div>
Curabitur ipsum risus, ultricies nec posuere at, finibus quis augue. Mauris ultrices massa quis ipsum tincidunt condimentum. Fusce feugiat id sapien non fermentum. Curabitur vel lectus laoreet velit eleifend tincidunt. Nulla tempus nisi nec lorem efficitur congue. Suspendisse laoreet arcu tempor est tempor pharetra. Sed suscipit vel lorem id elementum. Praesent vitae mauris justo. Vivamus non tellus ligula. Nunc laoreet tincidunt arcu eget maximus.
</div>
<div>
Mauris eu sagittis velit, quis vulputate ex. Vivamus pretium, urna venenatis scelerisque blandit, eros magna placerat ipsum, sit amet accumsan lacus erat non orci. Vestibulum sagittis fringilla mi, vel feugiat ante suscipit in. Sed pellentesque nulla urna, vel interdum augue placerat vitae. Fusce vitae tortor et libero tempus blandit. Donec rutrum venenatis faucibus. Proin luctus rhoncus mauris, nec dictum nisl dapibus eget. Phasellus sollicitudin orci nec augue ultrices, eu vestibulum dolor tincidunt. Integer lobortis eget nibh non ultrices.
</div>
<div>
Cras molestie lectus eget nisi mattis varius. Morbi feugiat in turpis eu fermentum. Nullam et tempus mi, eget ultricies ex. In cursus, lorem id aliquet eleifend, velit ipsum ultricies nisl, sed ultricies nisi arcu ut augue. Nulla pretium ligula et ipsum sodales, vel scelerisque est porttitor. Nulla vitae mi eget quam sodales efficitur at non ex. Fusce imperdiet orci et urna varius rutrum. Donec efficitur tellus non tempor varius. In mattis tortor non metus porttitor fermentum. Etiam dapibus quam augue, et sollicitudin sem feugiat quis. Vestibulum id tortor a elit tempus ultricies semper sit amet nunc. </div>
</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

Trouble experienced with the window.open() function on Safari

When using Safari, it can sometimes block the opening of a new tab through the window.open() function during an ajax call. To bypass this blocking, we must first call window.open() to open a new tab before making the ajax call. Refer to this Stack Overflow ...

increasing sticky header, refreshes the scroll location of the website

My website has a fixed header that expands to reveal more content when a button is clicked. However, I noticed that if the page has been scrolled down before clicking the button, the scroll position resets to the top of the page. To see this issue in acti ...

When the mouse is moved to the UL LI list, the border color of the Top Hover is reverted back to default

Can you assist me with this issue? I need to modify the code below so that the border color remains blue while a user selects an item from the UL LI list. Here is an image showing the current problem: And here is a picture of the expected outcome: For ...

Stylish CSS menu design

I am struggling to set up a top menu bar using float: left. How can I achieve the desired behavior for a top menu bar? The code snippet below demonstrates what I have tried so far: * { margin:0; padding: 0; } #menu { background-color: yell ...

Personalized element IDs and unique CSS styles

After editing the code snippet below... <div id="rt-utility"><div class="rt-block fp-roksprocket-grids-utility title5 jmoddiv"> I applied the changes in my custom.css file like this: #rt-utility .rt-block {CODE HERE} However, when attemptin ...

Delete any content that is not enclosed in tags

I am struggling with manually rendering Django forms and it's producing the following code. Is there a way to remove text without HTML tags, such as "Currently:" and "Change:", which are difficult to style with CSS? <div class="row align-cente ...

The textbox is not able to process the complete input string provided

I am having trouble with entering an email address into a textbox, for example [email protected], as it only accepts dd@g. Here is the HTML code: <input type="email" class="form-control ng-pristine ng-valid-email ng-invalid ng-invalid-required ng ...

Unable to post form data into database due to Javascript undefined data situation

I've been working on an HTML form that can interact with a PHP API to retrieve client data and then update user stats in a MySQL database. Currently, I am converting the data into a JSON object and using JSON.stringify to create a string for sending ...

Utilizing d3.js to implement a scatterplot with zoom functionality that focuses solely on zooming the axis without affecting

Having trouble creating a scatterplot with zoom functionality where only the axis is getting zoomed, not the data itself. Can anyone provide some assistance or insight on what might be wrong? If you're interested in checking out the project, here&apo ...

Is my directive not displaying the desired content on the HTML page?

I'm facing an issue with a custom directive in AngularJS that is supposed to draw a circle using SVG. However, upon loading the page, the circle doesn't appear, and even the text within the template is not showing up. What could be causing this ...

oversized user interface selection container

When using semantic-ui for my search form with large input fields, I am facing an issue where the select option field does not adjust its size. I have followed the documentation but it seems like I might be missing something. Can someone help me figure out ...

Can you provide instructions on creating a small border at the center of an h1 heading?

What is the best way to create a small border in the center of an h1 text element? ...

Is there a way to adjust the label size for a material ui TextField component?

My TextField element is defined like this: <TextField id="standard-with-placeholder" label="First Name" className={classes.textField} margin="normal" /> It currently appears as shown in the image below: However, I would like it to look mor ...

Split a number in PHP into individual HTML tags for formatting

Is there a way to split the number 12345 into individual digits using PHP like this: <span>1</span> <span>2</span> <span>3</span> <span>4</span> <span>5</span> ...

What is the method for configuring automatic text color in CKEditor?

https://i.sstatic.net/yEM3p.png Is there a way to change the default text color of CKEditor from #333333 to #000000? I have attempted to modify the contents.css in the plugin folder: body { /* Font */ font-family: sans-serif, Arial, Verdana, "Tr ...

Guide to generating a dropdown menu and linking it with data received from a server

I am completely new to Angular and recently received a project involving it. My task is to create a nested dropdown list for Json data retrieved from a server using Rest Api calls. The data contains a Level attribute that indicates the hierarchy level of ...

How come JSOUP fails to read in UTF-8 format?

I've been struggling to parse utf-8 using jsoup. I've tried everything I know and even searched on Google. My goal is: String tmp_html_content ="Öç"; InputStream is = new ByteArrayInputStream(tmp_html_content.getBytes()); Documen ...

Is it possible to redirect my PDF File to my PHP homepage?

Hi there, I've been looking for a solution to my issue. I have been using TCPDF-master to create a PDF report. However, after generating the PDF file and printing it out, I am unsure of how to redirect back to my transaction page. My current setup inv ...

Receiving form input through an express route and attempting to insert it into a MySQL database results in empty entries

Welcome everyone! I'm brand new to this and just starting out with express. It seems like I've hit a roadblock and can't figure it out on my own. After spending the day learning, I can't seem to get my message to appear properly in the ...

Tips for creating a subclass using jQuery

I am familiar with selecting the class "myClass" using $(".myClass"), but my question is how do I select the child link within an element with the class "myClass" using jQuery? Here is a sample of the code: <a href=#>Home</a> <div class ...