Adjusting the size of a division element to match the dimensions

Currently, I am still in the process of finalizing the remainder of the page, but I have encountered a minor issue. The problem lies in my image div not matching the height of the container. Although the image itself is the correct size, the image div appears slightly smaller.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="index.css">
</head>
<body>
    <div id="container">
    <div id="image">
        <img src="halie-west-25xggax4bSA-unsplash.jpg" alt="leaves and trees">
    </div>
    <div id="form">
        <fieldset id="info">    
            <h1>Let's do this!</h1>

            <div class="row">
                <div class="column">
                    <label for="first-name">First Name</label>
                    <input type="text" required id="first-name">
                </div>

                <div class="column">
                    <label for="last-name">Last Name</label>
                    <input type="text" id="last-name">
                </div>
            </div>

            <div class="row">
                <div class="column">
                    <label for="email">Email</label>
                    <input required type="email" id="email">
                </div>

                <div class="column">
                    <label for="phone-number">Phone Number</label>
                    <input type="number" required id="phone-number">
                </div>
            </div>

            <div class="row">
                <div class="column">
                    <label for="password">Password</label>
                    <input type="password" required id="password">
                </div>

                <div class="column">
                    <label for="confirm-password">Confirm Password</label>
                    <input type="password" required id="confirm-password">
                </div>
            </div>
        </fieldset>
        <div id="submit-button">
        <button id="submit" type="submit" method="post">Submit</button>
        </div>
    </div>
    </div>
</body>
</html>

In addition to that, here is my CSS:

body {
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}

#form {
    
    position: absolute;
    display:inline-block;
    width: 100%;
       
}

#info {
    width: 100%;
    border: none;
    box-shadow: 0 20px 20px -20px black;
    
}

.row {
    display: flex;
    justify-content: left;
}

#info h1{
    text-align: left;
}
.column{
    margin:10px;
}

.column label{
    display: block;
    text-align: left;
    padding:5px;
    
}
#info input{
    
    align-items: end;
}
#submit{
    height: 3rem;
    width:12rem;
    margin: 3rem 0 0 3rem;
    display:flex;
    justify-content: center;
    align-items: center;
    
}
#image{
    position: relative;
    width: 35%;
    height: 100vh;
    display: inline-block;
   
    
}
#image img{
    width: 100%;
    height: 100vh;
    object-fit: cover;
    
    
}
#container{
    display: inline-block;
    align-items: center;
    justify-content: left;
    height: 100%;
}

I'm attempting to resolve this issue before continuing with the login page since it will appear inconsistent during completion. I've attempted using chatgpt and conducted thorough searches without success. Due to my limited front-end experience, this small complication is perplexing. I believe finding a solution should be relatively straightforward.

Answer №1

It seems like you're looking for the following:

  • The image should occupy 35% of the width while the form takes up the remaining space

  • The image should fill the entire height of the viewport

  • No whitespace should be present below the image

I've experimented with the code across various viewport dimensions:

body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#form {
    flex: 1;
    box-sizing: border-box;
    padding: 20px;
}

#info {
    width: 100%;
    border: none;
    box-shadow: 0 20px 20px -20px black;
}

.row {
    display: flex;
    justify-content: space-between;
}

.column {
    flex: 1;
    margin: 10px;
}

.column label {
    display: block;
    text-align: left;
    padding: 5px;
}

#info input {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
}

#submit {
    height: 3rem;
    width: 12rem;
    margin: 3rem 0 0 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

#image {
    flex: 0 0 35%;
    overflow: hidden;
}

#image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#container {
    display: flex;
    flex: 1;
}

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

Creating a Runescape Tracker: What essentials should I include?

Hello everyone, I am a beginner in the world of programming and I am excited to learn. I have heard that the best way to learn is by working on a project. I have always been interested in creating a Skill Tracker for my clan. Can you offer any advice on wh ...

Displaying a hidden div using the jQuery .each() method

Attempting to validate a form using jQuery, the goal is to target all form fields with class="required" and utilize the .each() function to verify if the field is empty. If it is empty, a hidden div positioned relative to the field should be displayed. An ...

JavaScript's counter variable can become confusing when used in an if statement

Struggling as a beginner in javascript, I find myself stuck on writing an If statement that triggers after the fourth turn. My goal is to have an alert pop up once the user has clicked on four options. The counter variable "turns" was added to track prog ...

Is there a way to create a customized select handle using CSS?

Is there a way to create a resizable border that appears when a user clicks on the div? And when they move the mouse over it, can the cursor change accordingly? I also want the user to be able to drag the element's border and have the element resize a ...

Incorporate JavaScript code into an Angular UI-Router view

I can't seem to find an answer to this question anywhere, so I'm hoping someone here can help me out. In my AngularJS app, I am using ui-router to load multiple views into the same <ui-view> element. I am trying to implement Jquery UI&apos ...

Are HTML attribute names really case-sensitive? A topic filled with conflicting information

After learning that attribute names are case-sensitive, I found conflicting information. A source mentioned that attribute names are indeed case-sensitive. For example, the width attributes in <div> and <DIV> would be considered separate due ...

Ways to showcase a website within an HTML document using a URL?

Is it possible to show 2 webpages on a single aspx webpage? For instance, When a user opens the link for www.mywebsite.com, I would like to display both www.google.com and www.bing.com on my homepage. Behind the scenes, I will call two separate URLs an ...

What is the best way to showcase saved HTML content within an HTML page?

I have some HTML data that was saved from a text editor, <p style=\"font-size: 14px;text-align: justify;\"> <a href=\"https://www.xpertdox.com/disease-description/Chronic%20Kidney%20Disease\" style=\"background-color: tr ...

Looking to have the content aligned in the center of the parent container while also

Below is the code snippet I am working on, which utilizes Bootstrap 4: .resource{ border:1px solid red; } <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxP ...

The positioning attribute and flexible height in CSS are essential for creating dynamic

My goal is to create a layout with 3 DIVs inside a container, similar to table rows. top {height = 100px} / middle {height = dynamic} / bottom {height = 100px} I am trying to figure out the best approach to make the height of the middle div dynamic whi ...

Menu drop down offset in Internet Explorer 7

Having some difficulty with a dropdown menu specifically in IE7. The menu functions correctly in all other browsers, but in IE7 it seems to be misaligned for some reason. Any suggestions or insights would be greatly appreciated. Please refer to the menu co ...

What is the purpose of including a viewport meta tag on my website if I already have CSS media queries in place?

As someone who is just starting out with building websites, I have been delving into the world of meta tags. However, even after conducting thorough research, I am still unsure about the necessity of a meta viewport tag when I am already utilizing CSS me ...

When hovering over one div, both it and another div should be displayed simultaneously. The second div should continue to be displayed even when hovered over

I am looking to keep another div displayed when hovering over it - in this example, it says "hello." The div I want to remain visible is not a child element of the main div where I initiate the hover event. document.write("<base href=\"" + docum ...

Position the li elements within the ul at the bottom

I am trying to align a li element at the bottom of a ul list. +------+ | li1 | | li2 | | li3 | | | | | | | | li4 | +------+ Any suggestions on how to achieve this? MY ATTEMPTED SOLUTION: li4 { position: fixed; bottom: 0; } W ...

Generate random unique values from an array to populate a text input field in HTML. Display a message once all unique values have been shown

I have included an option code and text box below: <select id="sel" class="form-control input-lg" data-live-search="true"> <option value="">-- Choose Your Country--</option> </select><br/><br/><br/> &l ...

Is there a way to dynamically alter the heading color in Shopify liquid code?

After utilizing ChatGPT to review the code, I am uncertain if it is related to the color schemes. I am unsure of what I may be missing or doing incorrectly. While I can successfully alter the heading text, I am unable to change the color. Below is the code ...

Conditionals in Angular 2 using Sass

Looking to apply this style with Sass or CSS: IF :host.form-control MATCHES .ng-valid[required] OR .ng-valid.required THEN :host ::ng-deep input.form-control = border-left: 5px solid #42A948; Appreciate the help! ...

Aligning text to the right within a div that is placed inside an image element

I have a simple structure that looks like this: <div class="inline"> <div class="photo-group thumb_wrapper"> <img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQYZ35nsT0CRTlGBtNmPHikH74wXBldsPe8LQYfhXnzADYo-xSU" ...

Can a shape similar to an inverted circle be created using CSS and jQuery?

I'm stumped on how to create an inverted circle in the corners. I've included a picture for reference. https://i.stack.imgur.com/jeNdh.jpg Is it feasible to achieve this effect using CSS3 or maybe jQuery? ...

What are the steps to sending HTML emails from the default mail client on Mac and PC operating systems?

Currently, I am in the process of creating a website that allows clients to easily send an email with the content they are viewing. I want users to click on a button which will open their default mail client (compatible with both Mac and PC) and automatica ...