Issue with Div not fully occupying the remaining space on the page

Despite seeming like an easy HTML page and CSS setup, I have run into an issue. My goal is to make a DIV fill up the remaining space on the page and meet with another DIV at the bottom.

I've scoured the web and tried various solutions that I found, but it seems the most common approach involves using position:absolute. However, when I implement this, my Google map disappears and I can't change the position of the Google Map DIV from relative.

Currently, the display looks as shown in the image provided. What I really want is for the #map DIV to be centered and take up all available space.

View my site in Chrome element view

My HTML code:

<div id="wrapper">
    <div id="header">
        <h1>Find a Car Park</h1>
    </div>
    <div id="section">
        <input type="text" id="town" placeholder="Search for Town.." onkeypress="handle(event)" />
        <input type="button" value="Find Car Parks" onclick="codeAddress()" />
        <input type="button" value="View All" onclick="getAllCarParks()" />
        <input type="button" value="Your Location" onclick="loadUserScript()" />   
    </div>
    <div id="map">

        <div id="googleMap">

        </div>
    </div>


    <div id="footer">
        <p>hello</p>
    </div>
</div>


</body>

My CSS code:

body{
margin:0;
font-family: 'Cabin', sans-serif;
}
#header {
background-color:#2d89ef;
color:white;
text-align:center;
padding: 20px;

}
#wrapper{
position:absolute;
height:100vh;
width:100vw;

}
#section {
text-align:center;
padding-bottom:15px;
padding-top:15px;
width:100vw;
}
#footer {
background-color:#2c3e50;
color:white;
clear:both;
text-align:center;
padding-top:10px;
padding-bottom:10px;
bottom:0;
position:absolute;
width:100vw;
}

#map {
height:auto;
}

#googleMap{
height:65%;
}

input[type=button], input[type=submit], input[type=reset] {
background-color: #2d89ef;
border: none;
color: white;
padding: 16px 32px;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
border-radius: 4px;
}
input[type=text] {
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
color: darkgrey;
background-color: white;
background-image: url('../images/searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
}

Answer №1

Consider utilizing flexbox for better alignment.

<div style="display:flex;justify-content:center;align-items:center;">
  <div></div>
</div>

Answer №2

Implement this CSS snippet on the #map element to expand it to the full width and height of the webpage :

#map {
    display: block;
    width: 100%;
    height: 100%;
}

JSFiddle link

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

Using Javascript to display different div elements based on the type of mobile device

My goal is to use JavaScript to accomplish the following: 1- Check the mobile device type, if it is an ANDROID device, show the ANDROID_USERS div. If it is an IPHONE device, show the IOS_USERS div. 2- Display the above div only once during the first visit ...

Retrieve the content of a text field with jQuery

Check out this block of HTML: <div class="sub-middle-column"> <div class="div-header">Grandsire <a "#", class="table-control-focus sub-header-table-focus" id="table-control-focus-t" >abc</a> <ul class="table-controls h ...

Steps for Embedding an HTML Page into a Tab using jQuery

Within the tab labeled class=plots-tabs-heatmap, I am attempting to insert a new page using the code below. However, instead of seeing tmpdata/page2.html displayed on the tab, nothing appears. $('#plots-tabs-heatmap').html("tmpdata/page2.html"); ...

Flipboard-inspired CSS Animation

I have been following a tutorial regarding CSS flip effects and encountered some challenges. The tutorial can be found here. .flip-container { perspective: 1000px; } /* add more code here... */ <div class="flip-container" ontouchstart="th ...

How to set up an Angular animation using component input variables?

My goal is to introduce an @Input parameter that will define the timing of the animation in this demonstration of circle progress. However, the animation settings are currently specified within the @Component decorator, and it seems that this code does no ...

ASP.NET Core 2.1 struggling to implement Shared Layout view across all views

I am facing an issue where the layout view is not consistent across all pages on my website. While the home page and main pages share the same layout, other pages like the login page lack styling and images. Additionally, features like CRUD operations also ...

Issues with inline display not being rendered properly in HTML/CSS

I've been attempting to place an image and an h1 element on the same line. After researching online, I attempted using display:inline; for both the parent div element as well as each individual element. This is my current code: <div style="displa ...

Having troubles with angular due to doodle throwing errors?

https://codepen.io/tuckermassad/pen/rPYNLq I took the CSS doodle code from the above link and incorporated it into my angular component: <section class="main"> <css-doodle grid="5"> :doodle { @grid: 10 / 100%; } ...

Instructions on setting div opacity when Overflow is set to visibleExplanation on setting opacity for div with Overflow

In my HTML code, I have a div element and an image tag stacked one on top of the other. The div is smaller than the image. I have set the overflow property to visible for the div. My query is, when I add an image to the image tag, the content that overflow ...

Tips on emphasizing all div elements and incorporating navigation to each of them

I am seeking a method to enhance a div with highlighting when there is a click or mouseover event. For instance, changing or adding a border color using JavaScript on click or mouseover is straightforward. Recently, I have been contemplating the idea of a ...

Top button on my website fails to function

I followed a tutorial to add a "back-to-top" button, and it works on my JSFiddle but not on my live page. The button shows up in Safari but doesn't scroll up. Any ideas why? // Contact Form $(document).ready(function() { $("#contactfrm").submit(f ...

Troubleshooting issues with resource mapping in Spring 5 without the need for XML setup

I'm having trouble loading resources with the given configuration. Can anyone help out? I am working with Spring 5 and not using any XML configuration. Below is my resource handler function in the configuration page: @Override public void addResou ...

What is the best way to create an impact?

Need help fixing the parallax effect on this page. I attempted to implement a parallax effect but encountered some issues. Here is the JavaScript code: $objWindow = $(window); $('section[data-type="background"]').each(function(){ var $bgOb ...

Navigate divs with varying z-index values

I want to change the z-index of 3 divs by toggling them using jQuery, but I'm not sure how to do it. What I want is to click a button that relates to a specific div and increase the z-index of that div so the content inside it is shown. Currently, all ...

The HTML link is not directly attached to the text, specifically in Internet Explorer

When viewing my website in Chrome, the menu links in the Header function correctly. However, in Internet Explorer (specifically version 11), hovering over 'HOME,' 'LISTINGS,' or 'AGENTS' reveals that the displayed URL is incor ...

CSS - How can text and images be effectively combined for a visually appealing design?

We're tasked with designing text in the following format: Text in English XXX Text in English XXX Text in English. The XXX placeholders need to be replaced with images that have the same height as the English text. Is there a better solution for th ...

Distinguish the disparities between mobile and desktop devices

I need a solution for adjusting the layout of a component based on the device it is viewed on. For mobile devices, I want the content to stack vertically like in this example: https://codesandbox.io/s/material-demo-forked-ktoee?file=/demo.tsx. However, o ...

Behavior of floating footer in Wordpress across different web browsers is inconsistent

I'm facing an issue with the footer of my WordPress website, where it behaves differently in Chrome and Firefox. In Chrome, the right part of the footer seems to be moving out of alignment with the left part, while it displays correctly in Firefox. Y ...

Strange occurrences with HTML image tags

I am facing an issue with my React project where I am using icons inside img tags. The icons appear too big, so I tried adjusting their width, but this is affecting the width of other elements as well. Here are some screenshots to illustrate: The icon wit ...

Is it possible to add border radius to the scrollbar in Firefox?

I'm trying to make the scroll bar in Chrome compatible with Firefox, but I can't figure out how to give it a border radius. Chrome scroll bar css /* Store selector */ /* width */ .lhh::-webkit-scrollbar { width: 6px; height: 56px !important ...