The div extends beyond its parent due to its height

This issue is concerning.

https://i.stack.imgur.com/on8t9.jpg

The border of the div extends beyond the red line.

I have set this for body and html:

html {
  height: 100%;
}
::-webkit-scrollbar {
    width: 0px;
    background: transparent; /* make scrollbar transparent */
}

body {
  height: 100%;

  background:url('http://sf.co.ua/13/03/wallpaper-2682923.jpg') no-repeat center center fixed;

    -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;

}

Here is my HTML setup:

<div style="margin-top: 10%; height: 100% !important;" class="container-fluid">
        <div class="bodyc mx-auto">
            <div style="background-color: orange; border-top-right-radius: 15px; border-top-left-radius: 15px;">
                <ul class="nav nav-pills font-weight-bold">
                  <li class="nav-item">
                    <a class="nav-link active active-orange" style="border-top-left-radius: 15px !important;" href="#">HOME</a>
                  </li>
                  <li class="nav-item">
                    <a class="nav-link text-dark" href="#">STAFF LIST</a>
                  </li>
                </ul>
            </div>

            <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
              <ol class="carousel-indicators">
                <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
                <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
                <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
              </ol>
              <div class="carousel-inner">
                <div class="carousel-item active">
                  <img style="height: 250px !important;" class="d-block w-100" src="https://i.imgur.com/pxfQAPP.jpg" alt="First slide">
                </div>
                <div class="carousel-item">
                  <img style="height: 250px !important;" class="d-block w-100" src="https://i.imgur.com/IFNufte.jpg" alt="Second slide">
                </div>
                <div class="carousel-item">
                  <img style="height: 250px !important;" class="d-block w-100" src="..." alt="Third slide">
                </div>
              </div>
              <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="sr-only">Previous</span>
              </a>
              <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="sr-only">Next</span>
              </a>
            </div>

            <div style="height: 100% !important;">
                <div class="row" style="height: 100%">
                    <div class="col col-lg-9">
                        <div>

                        </div>
                    </div>
                    <div class="col col-lg-3">
                        <div style="border-left: solid red; height: 100% !important;">
                            test
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

The red line should align with the end of the white div,

<div style="border-left: solid red; height: 100% !important;">

However, it extends further down without reason.

Additionally, I am unsure why the white div doesn't reach the bottom even with a height of 100% specified:

.bodyc {
    position: relative;
    background-color: white;
    width: 90%;
    border-radius: 15px;
    height: 100% !important;
}

Bootstrap framework is being used in this setup.

JSFIDDLE

https://jsfiddle.net/8eddeuu1/2/

Answer №1

In order to address the issue of the red border line, I devised a quick solution: simply add this CSS rule:

overflow: hidden;

to the .bodyc class.

The reason why the white div does not extend all the way down is because "height: 100%" may not function as expected in CSS. Percentages in CSS are relative to the parent element. For example:

<div id="outer" style="height: 1%;"><div id="inner" style="height: 100%;"></div></div>

In this scenario, the inner div will not exceed the height of the outer div. They will be equal in height.

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

Is there a way to make a Bootstrap grid with four columns span across two rows in the second column?

How can I create a Bootstrap grid with four columns where the second column spans two rows? Hello, I am looking for help to achieve a portfolio grid layout with 4 columns (refer image here) and have the second column span 2 rows. I plan to include images ...

Achieving left text alignment in CSS for an excerpt using the Ultimate Posts Widget on Wordpress

I've been trying to align the text in the excerpt of a widget called "To-Do List" on the left sidebar. I attempted to set the text-align property to left for the excerpt text, targeting the p tag within the .widget_ultimate_posts, .uw posts using CSS ...

The issue of PHP timing out occurring within a public function

After pulling a "large" SQL query from the database with 50,000 records and completing it in about 5 seconds, I run it through a function to create an HTML table. However, the process keeps timing out for some reason. If I limit the query to less than 30k ...

What are the drawbacks of utilizing CSS word-wrap across all elements on a website?

Is there a downside to utilizing the CSS property word-wrap:break-word in this manner? body { word-wrap: break-word; } The definitions for the values of this property are as follows: normal: Breaks words only at allowed breakpoints break-word: Perm ...

I am curious if there is a wysiwyg web editor extension specifically designed for VS2010 available?

In my experience, I have been working with C#, HTML coding using VS2010 and MVC. Utilizing VS2010 has proven to be an invaluable tool for me in this process. Currently, I find myself needing to create some straightforward static web pages. I am wondering ...

Import of Bootstrap causing disruption in positioning of <figure> element

Check out this codepen example: https://codepen.io/anon/pen/Xgqjyq h2 { color: #111; font-family: 'Open Sans', sans-serif; font-size: 20px; font-weight: bold; text-align: center; } .content { margin-left: 5px; margin-right: 5px; t ...

Is the 404 error a result of the ajax code?

I'm currently working on a form that utilizes AJAX to validate and interconnect various form elements. Below is a simplified version of my code: <?php if( isset( $_POST['create_transaction'] ) ) { // do something } ?> <div> ...

Is there a way to retrieve information from all pages of a table on a webpage using Chrome?

On a webpage, I have a table containing 100 rows that are displayed 20 at a time. By clicking "next page," I can view the following set of 20 rows and the table view is updated accordingly. I am able to access the data for each batch of 20 rows using dev ...

What is the best way to implement pushstate degradation – using backbone.history or history.js?

I am interested in implementing pushstate functionality, which involves making an ajax request, changing the URL, and adjusting the browser history stack. However, since pushstate is not universally supported by all browsers, I need to find a workaround f ...

When the draggable item is released near the drop zone, allow drag and drop to combine

In my latest project, I created a fun game that involves matching different shapes. The goal is to drag the correct figure next to its corresponding shadow figure for a perfect match. Currently, if you partially overlap the square with its shadow, the game ...

Creating a Dynamic Canvas Rendered to Fit Image Dimensions

I'm struggling with a piece of code that creates an SVG and then displays it on a canvas. Here is the Jsbin Link for reference: https://jsbin.com/lehajubihu/1/edit?html,output <!DOCTYPE html> <html> <head> <meta charset=&qu ...

Switch back JSON in php script

After receiving a JSON object with an unspecified number of key/value pairs, I need to send it from my $.ajax function to a PHP script. The PHP script must then revert the JSON object and send it back to jQuery. {"First name": "John", "Contact": "2323",.. ...

Adjust the scrollbar color when hovering over a particular div

Is there a way to change the color of a div's scrollbar when hovering over the div without assigning an id to it? I've attempted the following methods so far: div:hover { ::-webkit-scrollbar {color: black} } and div:hover + ::-webkit-scroll ...

Explore/Discover feature on a website

I'm currently working on a webpage where I am querying a database and retrieving file paths. I have successfully displayed the path from the database on my page. Now, as an enhancement, I would like to add an 'Open' button next to the displa ...

center a horizontal line using StyledSheets in your project

After drawing a horizontal line, I noticed that it is positioned towards the left side of the screen. I am hesitant to increase its width. Are there any other methods to move it to the center? I attempted wrapping it with another view and using alignConten ...

HTML counterpart to PHP's include for JavaScript components

I am searching for a Javascript alternative to a method I have been using in PHP. Specifically, I want to streamline the basic setup of my pages: <!DOCTYPE html> <html lang="en"> <head> <meta ch ...

Altering Hues with a Click

One thing I wanted to achieve was changing the color of a hyperlink once it's clicked. I managed to make it work by using the code below: var current = "home"; function home() { current = "home"; update2(); } function comp() { current ...

Image staying in place when browser page is resized

Half page browser Full page browser Hello everyone, I could really use some assistance with my program. I'm trying to figure out how to keep my robot in the same position when switching from a half-page browser to a full-screen browser. Currently, w ...

Launching a program through a web browser - a step-by-step guide

I am looking to create a specific sequence of events: A web browser opens, and a user logs in (the exact action is not crucial) The user is then redirected to a new page where another program should automatically open This process is similar to what happ ...

The integration between React hook form and reactstrap input components is not functioning properly

Having an issue with react-hook-form and reactstrap. The component List.jsx is causing trouble: import { useContext, useEffect } from "react"; import { ListContext, ADD_LIST } from '../providers/ShoppingListProvider'; import { Link } from "react- ...