Expanding Div Heights that Adjust to the Browser's Width

Looking to set up a responsive height for a div, almost there but facing some distortion when resizing the browser. Here is the fiddle file for reference: https://jsfiddle.net/td5n8ky9/10/

The issue lies in the bottom 2 divs - aiming for a grey bar the width of the screen to contain 3 'box.jpeg' files while the rest of the page below remains white. Upon browser resize, notice the height issue with the grey bar. Hoping to resolve this without Jquery and additional media queries for smoother transitions. Appreciate your help!

SOURCE CODE

<div class="container">
        <nav>
            <ul id="mobile_active">
                <li class="link"><a href="#">About Us</a></li>
                <li class="link"><a href="#">Creative</a></li>
                <li id="logo"><a href="#"><img src="links/Logo.png"/></a></li>
                <li class="link"><a href="#">Portfolio</a></li>
                <li class="link"><a href="#">Contact Us</a></li>
            </ul>
        </nav>
        <header><a class="mobile_menu"></a></header>
</div>
<div class="line"></div>
<div class="container">              
    <div id="G">
       <img src="links/06-Grafiks-G.png"/>
    <div id="Text-Scroller">
       <h1>headline</h1>
       <p>Body Text</p>
    </div>
 </div>
 </div>
<div id="Gray"></div>
<div class="container">
    <article class="newsfeed"><img src="links/box1.jpg"/></article>
    <article class="newsfeed"><img src="links/box2.jpg"/></article>
    <article class="newsfeed"><img src="links/box3.jpg"/></article>
</div>
<div class="container">
        <div class="contact"><p>Address<br>Location</p></div>
        <div class="contact"><p>Phone • Fax<br>Email</p></div>
        <div class="contact"><p>Hours<br>Closed</p></div>
    </div>
</div>

CSS

.container {max-width: 950px; margin: 0 auto; position: relative;}
.line {clear:both; border-bottom: medium solid #bbb1a6; overflow:visible;}
.contact{width:27.75%; padding-left:2.75%; background-color:#FFF; height: 73%; padding-right:2.75%; float:left;}
...

Answer №1

Implement padding-bottom using a percentage value along with setting the height to 0.

#Gray {
    width: 100%;
    height: 0;
    padding-bottom: 31%;
    background-color: #bbb1a6;
    position: absolute;
}

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

Design flaws occur in Bootstrap Navbar dropdowns when the screen size is reduced

I am experiencing an issue with this JS Fiddle https://jsfiddle.net/uvkt8z7j/16/ where the design gets distorted when I click on the dropdown menu while the screen is small. I want to maintain the same behavior as when the screen is large. <body styl ...

Identify when a div reaches the end of the screen using CSS

I've developed a custom dropdown feature using Vue 2 and TypeScript to meet our specific requirements (without relying on jQuery). The dropdown functions correctly, opening the options list downwards when the main box is clicked. One enhancement I a ...

The CSS styles are not being rendered on the page

My simple static html/css project seems to be having trouble applying styles to the html elements in stackblitz. You can view the project here. I'm wondering if there might be an issue with linking the css file using the link tag, or perhaps it's ...

What steps should I take to effectively configure the header cache on my website?

After navigating through various links and attempting different solutions such as adding <meta HTTP-EQUIV="EXPIRES" CONTENT="Thu, 31 Dec 2015 12:00:00 GMT"> to my header without success, I am struggling to find a comprehensive guide on how and wher ...

Failing to hide a div on hover: Hoverintent's shortcomings

When I hover over the div with the unique identifier id="navbar", it doesn't seem to trigger any actions. I have included the following script in my document head: <script type="text/javascript" src="https://ajax.googleapi ...

Exploring Django's HTML QuerySet

Is there a way to verify if a student exists in the database class table, given that the student is assigned as a foreign key in the table? I am looking to achieve this without opening another loop. index.html: <ul> {% for student in studentList %} ...

"Here's how you can mark an option as selected in Angular, either from the component or the HTML file

When it comes to my form, I have a select menu that sends data to an SQL database and then fetches it back when it is called for editing. The value being edited should be displayed in the select menu option as selected. Here's a peek at my code: < ...

Troubleshooting the inability to set percentage values in Bootstrap styling

My goal is to create a bar with thin bars, but my use of Bootstrap limits my control over sizes. <template> <div class="container-fluid mx-auto"> <div class="row"> <div class="square rounded-pill&qu ...

Tips for effectively utilizing the page-break property within CSS

I am faced with an issue on my HTML page where multiple angular material cards are being displayed: ... <mat-card class="mat-card-98"> <mat-card-header> <mat-card-title>THIS IS MY TITLE</mat-card-title> < ...

When you add the measurements of two images to the top bar, you get the viewport size

Requirement 1: A top bar measuring 46px in height Reqirement 2: One photo positioned at the top and another at the bottom I have attempted the techniques mentioned on How to resize an image to fit in the browser window?. However, the images still appear ...

When zoomed in, the div background gives off a crisp white appearance

When I zoom in on a div with a background color or border, it appears completely white. Strangely, this issue doesn't happen when I zoom in on the Facebook site. This picture illustrates the problem more clearly. What could be causing this issue? H ...

How to embed HTML code within PHP using a conditional variable

I've encountered an issue with a PHP code that sends emails containing HTML templates. The HTML template includes PHP variables such as Name and Email. <strong>Name: {name} </strong> As the email template is lengthy, I have included ...

Switch the Header Image on a Page in WordPress

I am currently using the Sunrise Theme from s5themes.com and I have a question regarding the header image on individual pages. It seems that all pages are displaying the same header image as the homepage, which is not what I want. Attached below is a scre ...

The usage of uppercase letters in HTML attributes

I'm struggling to get animation working on my chart. I have been using jQuery's append function to add an animation tag to my HTML page, but for some reason the animation isn't displaying properly. The issue seems to be related to the capita ...

Font that has been downloaded is not showing up on the HTML document

I recently downloaded a new font and ensured the file location is correct, but for some reason it's not working: <style> @font-face { font-family:"myfont"; src: url('fonts/Helvetica85Heavy_22449.ttf'); } h1 { font-family: ...

What is the best way to create a hover effect for this text?

When I hover over the image div, the text section will smoothly appear from the bottom. You can see an example of what I want here. Below, you'll find the HTML and CSS code I've implemented for this effect. ============================== ...

The Selenium XPath isn't able to find the modal

I'm trying to target this specific input field: `(name="BtnOK" value="TAMAM" class="BoxButtonOK")` using xpath after a modal popup appears. I can't rely on .FindByClass because there are identical classes on the main page, but I specifically ne ...

Is it possible to personalize the Carousel-indicators feature within react-responsive-carousel?

I am currently utilizing the react-responsive-carousel library. I would like to modify the default indicators CSS, changing the dots shape to a line shape. Here is my code snippet: <CarouselWrapper sx={{ marginTop: "124px", maxHeight: & ...

Positioning an absolute div inside a relative div within a v-for loop while using VueJS and Element UI

I am experimenting with rendering a list of <el-card> items using a transition-group. Each card has a front and back side that flip when a button is clicked. To achieve a smooth flip transition, I need to apply the style: position: absolute; top: 0; ...

Styling using CSS is effective only when applied locally, as it does not function properly on GitHub Pages

Although I have come across similar questions to the one I am facing, none of the solutions provided seem to work for me at the moment. My CSS file loads and functions as expected when tested locally, but once I upload it to GitHub, it stops working. In my ...