Applying 100% height to a div element for positioning

I would like to achieve the following layout:

The navigation should be fixed at the top, and the height of the div with the background image should be 100%. I want to place content below the image.

My issue is that when I set the positioning of the image's div to 'relative', I am unable to set the height to 100%

.container ul {
margin-left: 50px;
}

.nav {
background-color: #D3D3D3;
height: 40px;
position: fixed;
width: 100%;
z-index: 1;
opacity: 0.6;
}

.nav li {
display: inline;
}

a {
color: white;
text-transform: uppercase;
text-decoration: none;
padding-left: 20px;
font-family: "Comic Sans MS", "Comic Sans", cursive;
font-weight: bold;
}

.jumbotron {
background-size: cover;
background-image: url('http://www.apothekenkurier.de/uploads/pics/haut.rg.jpg');
position: relative;
width: 100%;
height: 100%;
}

.content {
height: 100px;
background-color: gray;
}
<div class="nav">
  <div class="container">
    <ul class="pull-left">
      <li><a href="#">Link 1</a></li>
      <li><a href="#">Link 2</a></li>
      <li><a href="#">Link 3</a></li>
      <li><a href="#">Link 4</a></li>
    </ul>
  </div>
</div>

<div class="jumbotron">
</div>

<div class="content">
</div>

Answer №1

Creating an Image Ratio with Padding

If you're searching for a solution, this might be it.

.jumbotron {
  background-size: cover;
  background-image: url('http://www.apothekenkurier.de/uploads/pics/haut.rg.jpg');
  position: relative;
  width: 100%;
  height: 0; /* Modified */
  padding-bottom: 75%; /* Establishing height to width ratio */
}

Learn more about creating responsive elements that maintain their aspect ratio

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

Ways to align a div in relation to a span element?

I have a large block of text within a div. I am seeking a way to create a hover effect on specific words within the text, which will then display a div below the word containing a customized div. This functionality resembles the feature on Wikipedia where ...

Tips and instructions for assisting IE6

What are some important tips and guidelines to consider when designing websites that need to be compatible with Internet Explorer 6? I'm not interested in a detailed list of known bugs. I want general advice on preferred elements for certain tasks, f ...

What is the manual way to activate Ratchet's push feature?

I am facing an issue with a link that triggers a search function. Currently, the link is working as expected. However, I am having trouble getting the search to be executed by pressing the 'enter' button. Here is my code snippet: $('#sea ...

Exploring the functionalities of scss and minified files within Visual Studio 2017

I have very little knowledge of scss. In our Visual Studio 2017 solution explorer, there is a .scss file called Theme6.scss. When I expand it, I see a file named Theme6.css. Upon expanding that file, two more files are revealed: Theme6.css.map and Theme6. ...

Choose the singular Element lacking both a class or an ID

I came across this and that question, however, they are both focused on Javascript. I am searching for a way to target the lone div that does not have an ID or Class assigned to it. For instance: <body> <div class="X" ... /> <div class="Z ...

What is the best way to choose $(this) within a JavaScript expression inside a template literal?

Is it possible to use template literals in the append method and get the index of the row generated? I understand that calling "this" inside the function selects the specified selector passed as an argument. $(document).on('click', '.ad ...

Guide on storing user input data in an array

HTML: <span *ngFor="let cust of customs"> <div class="custominfobackground col-sm-12"> <input type="email" id="widget-subscribe-form-email" name="cust{{$index}}" class="form-control required email" [formControl]="form.controls[&apos ...

Guide on retrieving a file through an HTTP request with restricted cross-origin access restrictions

Having some issues with downloading files from specific links, such as . My goal is to automate the download process for these redirected files. The challenge I'm facing is that trying to access the link directly through a web browser just gives me a ...

Aligning a Form in HTML/Bootstrap

Is there a way to center this form properly? Despite my attempts to adjust the div classes and styles, I still can't get it to align in the center. I've explored using flexbox and other tools, but no matter what I do, the input field stubbornly ...

Can a border not be added to a <tr> in an HTML table using CSS for any specific reason?

I am facing an issue with the borders of a table row (tr) when applying CSS styling. The tr has a class called "underRow" which is supposed to add a border at the bottom. In my CSS, I have defined the following for the ".underRow" class: .underRow { ...

Ensure that the background image is perfectly fitted within the second background image

I am facing a challenge with two images - a frame and another image that needs to fit perfectly inside that frame. The tricky part is ensuring that the layout remains responsive. The two images are: https://i.sstatic.net/XWsTq.png Here is how it should ...

A JavaScript code snippet that stores the total number of bytes read from a CSV file in a variable

I currently have a CSV file located on a web server that is regularly updated with numeric and string data of varying lengths. I am seeking a solution to calculate the total byte values of each row when reading the file, as the byte count is crucial due ...

Generate Random Messages in a pop-up window using window.alert functionality in Javascript

As a first-year Digital Arts student, I have been tasked with creating a basic E-Learning website for mathematics. The concept is simple - the user is asked to solve math problems like "What is 7 times 7?", enters their answer, clicks a button, and an aler ...

What could be causing the background of the wrapper image not to display?

I am looking to add a background image specifically within the wrapper div on my website. Below is the HTML document: <!DOCTYPE html> <html lang="en"> <head> <meta charset="<?php bloginfo('charset'); ?>"> &l ...

Convert XML data into a structured table format

We have an XML file named "servers.xml" that needs to be parsed. This file is located on the same server where we want it to be parsed, in the same folder. <root> <list> <server> <server name="28 Disconnects La ...

Creating a responsive layout with organized rows and columns using Bootstrap

I'm currently facing some challenges with the arrangement of columns and rows in a bootstrap layout. I'm unsure if it's feasible to achieve what I have in mind using Bootstrap's grid system. Here is the layout I have for larger devices ...

Alert popup onclick feature is malfunctioning

SOLVED: I finally figured out the issue and it is now working perfectly. I had to manually switch to Chrome instead of using the Brackets live viewer. I want an alert box to pop up when the "Home" link is clicked on my website. I tried creating a separate ...

Is there a way to prevent an iframe from being recorded in Chrome's browsing history?

I'm in the process of developing a Chrome extension that inserts an Angular application into the user's browser window to create an interactive sidebar. I've been successful in most of my goals by inserting an iframe through a content script ...

The Harp server generates excessive white space within HTML documents

Running a blog on Harp has been smooth sailing, except for one issue that I can't seem to figure out. The project utilizes EJS and the problem lies in the outputted HTML containing excessive whitespace. I've attempted to minimize it, especially w ...

Create a boundary behind the title on a see-through backdrop

How can I create a design where there is a line to the left and right of a headline? Usually, I would use border-top on the surrounding element and style the headline with some CSS properties like this: h2 { margin-top: -10px; padding: 0 5px; b ...