The div's background height doesn't adjust according to the content in my project, and I'm struggling to fix it

On industrukt.pl/dev/ap/barbara.html, I am struggling to make the background color of the article section extend 100% of the photos. Currently, I have set a constant height value, but this solution is not ideal. When the browser window is resized to mobile or tablet resolution, the background color does not cover the entire photo content.

https://i.sstatic.net/XE2Fh.png

Any suggestions on how to fix this issue?

Here is my HTML code:

<div class="content">
    <aside>
        <ul>
            <li style="margin-bottom:30px"><a href="index.html#tresc">selected works - home</a></li>
            <li style="margin-top:30px;" class="selected"><a href="#">Barbara</a></li>
            <li><a href="fellig.html">Fellig</a></li>
            ...
            [Full list of items in the aside section]
        </ul>
    </aside>

    <article style="margin-top:135px">
        <div class="photos">
            [...] 
            [List of thumbnail images for the article]
            [...]
        </div>
    </article>
    
    <!-- End Content -->
</div>
<div class="bcg"></div>

This is my CSS code:

.content {
    width: 100%;
    height: 100%
    background-color: #fff;   
    padding-bottom: 30px;
    position: relative;
    overflow: hidden;
}

article {
    padding-left: 37px;
    max-width: 1200px;
    font-family: Open Sans;
    font-size: 10px;
    letter-spacing: 1px;
    float: left;
    position: absolute;
    padding-top: 40px;
    margin-left: 272px;
    z-index: 100;
}

.photos {
    background-color: red;
    height: 100%;
    background-repeat: repeat-y;
}

.bcg {
    background-color: #fff;
    height: 100%;
    background-repeat: repeat-y;
    overflow: hidden;
}

Answer №1

Don't forget to add a semicolon ; after the height property.

.content {
width: 100%;
height: 100%;
background-color: #fff;   
padding-bottom: 30px;
position: relative;
overflow: hidden;
}

If you check the browser console, you may see an error message like:

Expected end of value but found 'background-color'. Error occurred while parsing the value for 'height'. Declaration will be ignored.

To view the entire content, consider removing the overflow: hidden property. It doesn't seem necessary for your website located at

http://industrukt.pl/dev/ap/barbara.html
.

Visit JSFiddle for experimentation.

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 it possible to optimize and condense CSS code for a more streamlined and efficient style?

I've defined the following styles in an external CSS file. .callButton { width: 100px; height: 25px; float: right; /* other styles here */ background-img: url('images/callButton.png'); } .otherButton { width: 100px; height: 2 ...

Click to reveal additional images once the "show more" button is pressed

Hey there! I'm currently working on implementing a feature where, upon clicking "show more", 3 images will be displayed. And if the user clicks again, another set of 3 images will appear, and so on. I seem to be facing some difficulties with the JavaS ...

"Troubleshooting Issue: Angular Material Expansion Panel malfunctions when used in conjunction

As I embark on my journey with Angular Material, I have encountered a roadblock. The Expansion Panel is not functioning as expected (I can see the panel but am unable to open/close it). After some investigation, I realized that this issue arises when impo ...

How to ensure the footer stays at the bottom of the page even when the Treeview control expands

Greetings Everyone! I'm facing an issue with keeping the footer pinned at the bottom of the page. The treeview control I'm using overlaps the footer when expanded. Can anyone assist in ensuring the footer remains at the bottom of the page? < ...

How come I don't have to specify the relative path in my HTML file to include a JavaScript file when using Express JS?

I am currently in the process of building my very first project from scratch. As I was setting everything up, I ran into an issue with using relative paths to reference my javascript file in my index.html file. Strangely enough, simply referencing the scri ...

Strange new alignment when using float

Looking to arrange a series of menus using the float and clearfix method, but encountering some issues. Specifically, trying to align the menu group to the right without setting a uniform width due to varying text lengths. However, adding padding causes th ...

Challenges arise in CSS layout when incorporating PHP code

I have encountered an issue with the navigation bar on my webpage. When I insert the HTML directly into the page, there is no space above it. However, when I include an external HTML file using PHP's include function, a margin appears above the naviga ...

Modify styling of complete list upon clicking in React

For my latest project, I developed a basic todo application using React. One of the key features is that when a user clicks on a checkbox, the corresponding todo item's CSS changes to show a strike-through effect. Additionally, a button appears on hov ...

"Stylish footer design in CSS featuring a sleek overflow scrollbar

Perhaps the most straightforward way to demonstrate this is by providing a direct link to the website where the addition should be made. I am in desperate need of a basic footer that remains fixed at the bottom of the page, regardless of the amount of con ...

hiding elements yet passing down

Despite disabling the style sheet, a dynamically created form is displaying strangely. This form will show or hide various details based on selected options. For instance, many of the elements are generated with C#.net... formOutput += "<div class=&bs ...

A comprehensive guide on incorporating Jest for testing localStorage

I have attempted to mock localStorage following the advice from another source, but I am struggling to get the tests to pass despite several attempts. Below is the code for the localStorage mock: class LocalStorageMock { constructor() { this.stor ...

Basic HTML and JavaScript shell game concept

After spending several days working on this project, I am struggling to understand why the winning or losing message is not being displayed. The project involves a simple shell game created using HTML, JavaScript, and CSS. I have tried reworking the JavaSc ...

How can I programmatically click on a <td> element in VBA that has both an id and name attribute set (it's a search button)?

I'm attempting to automate the clicking of a button using VBA. When inspecting the element, I found the following code snippet: </td> <input name="btnSearch" id="btnSearch" style="width: 150 ...

Disabling the NavBar occurs when aligning it to the right

When attempting to align my NavBar to the right, I noticed that using float:right caused it to shift to the right but become unresponsive. Take a look here: goo.gl/46yUrt Snippet of Code: /** * 4.2 Navigation * --------------------------------------- ...

The database is failing to retrieve user information

I am struggling to display the username from a database on my UserHome.php page. Unfortunately, I am not seeing anything displayed. Below is the code snippet that I have implemented in an attempt to show the name. server.php : $host = "localhost" ...

Laravel's blade allows you to easily convert an HTML element to an array using the same name

I have two separate divs with similar content but different values <div id="tracks-1"> <div> <label>Song Title</label> <input type="text" name="tracks[song_title]" value=""> <input type="text ...

Separating stylesheets, head, and other elements in a curl response

After successfully using curl to retrieve an external site, I noticed that the results were interfering with my own content. The CSS from the external site was affecting my webpage's layout and z-index values were conflicting. I am seeking a solution ...

The scroll-to-top arrow remains concealed when the height of the html and body elements is set to 100

I recently added a scroll-to-top arrow using Jquery, and it's functioning flawlessly. However, I encountered an issue when I set body and html to a height of 100%, as it mysteriously disappears. View this fiddle for reference The HTML structure is a ...

Tips for creating multiple diagonal lines with CSS and HTML

Is there a way to create multiple diagonal lines within a rectangle using CSS and HTML from the start? I am interested in incorporating diagonal lines at the onset of the rectangle. Here is an example code that displays the rectangle: <div className={ ...

What is the process for converting a URL or HTML document to a PDF using the html2pdf JavaScript library?

I am working on creating a button that utilizes the html2pdf library to convert an HTML page into a PDF. Instead of selecting an element with query selector or getElementById, I would like to pass a URL because the page I want to convert is not the same as ...