What is the best way to eliminate the space following the image?

Something strange happened, and now there's a big gap following the top image. I was working on making the code responsive and then inserted this image, which messed everything up. Any ideas on what I might be doing wrong? I want the image to be closer to the 2 columns of content below it.

I've tried adjusting the flexbox and the image, but so far, nothing is working.

    html {
    width: 960px;
    font-size: 100%;
    font-family: "Arial", sans-serif;
    color: #112271;
    margin: 0 auto;
    }
    
    .flex-container {
    width: 960px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    }
    
    .banner-image {
    width: 960px;
    min-height: 50px;
    background: #112271;
    padding-top:  10px;
    padding-left: 20px;
    padding-bottom: 10px;
    }
    
    .banner-image h1 {
    color: white;
    }
    
    .topics-sidebar {
    width: 320px;
    padding-top: 40px;
    }
    
    .main-content {
    width: 640px;
    padding-top:  40px;
    }
    
    .individual-post {
    margin-bottom: 50px;
    }
    
    .main-content p.return-link {
    margin-bottom: 50px;
    }
    
    /* Left arrow for links that return to index.html */
    
    i {
    border: solid #112271;
    border-width: 0px 2px 2px 0px;
    padding: 5px;
    display: inline-block;
    }
    
    .left {
    transform: rotate(135deg);
    -webkit-transform: rotate(135deg);
      }
    
    
    ul {
    list-style-type: none;
    padding: 0;
    line-height: 2;
    }
    
    a:link, a:visited {
    color: #112271;
    }
    
    a:hover {
    color: #F09F08 ;
    }
    <!DOCTYPE html>
    
    <head>
    <link rel="stylesheet" href="../html-visual/styles.css">
    <title>HTML & CSS Cheatsheet</title>
    </head>
    
    <body>
    <div class="flex-container">
    <div class="banner-image">
    <h1>HTML & CSS Cheatsheet</h1>
    </div>
    <div class="topics-sidebar">
    <h3>Topics</h3>
    <ul>
    <a href="getting-started.html"><li>Getting Started</li></a>
    <a href="css-intro.html"><li>CSS</li></a>
    <a href="flexbox.html"><li>Flexbox</li></a>
    <a href="forms.html"><li>Forms</li></a>
    <a href="image.html"><li>Images</li></a>
    <a href="links.html"><li>Links</li></a>
    <a href="lists.html"><li>Lists</li></a>
    <a href="responsive-design.html"><li>Responsive Design</li></a>
    <a href="resources.html"><li>Resources</li></a>
    <a href="tables.html"><li>Tables</li></a>
    </ul>
    </div>
    <div class="main-content">
    <h2>Recent Posts</h2>
    <div class="individual-post">
    <a href="#"><p>General Template</a> | Last Updated Dec. 3, 2019</p>
    <p>This is the basic layout for a webpage.</p>
    </div>
    <div class="individual-post">
    <a href="#"><p>Linking a CSS File</a> | Last Updated Dec. 3, 2019</p>
    <p>Each HTML page must include a reference to the external style sheet file.</p>
    </div>
    <div class="individual-post">
    <a href="#"><p>Box Model</a> | Last Updated Dec. 3, 2019</p>
    <p>The CSS box model is essentially a box that wraps around every HTML element. It consists of: margins, borders, padding, and the actual content.</p>
    </div>
    </div>
    </div>
    </body>
    
    <footer>
    </footer>
    </html>

Answer №1

If you want to improve the layout, consider removing

padding-top: 40px
from both .main-content and .topics-sidebar elements.

Alternatively, you can adjust them to different values based on your needs.

An alternative approach would be to define

margin-bottom : (YOUR_VALUE)px
for your .banner-image element instead.

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 a Bootstrap dropdown menu featuring various options within an icon container

I have designed a blade with a signboard containing multiple columns, each displaying its name, color, and assigned cards (screenshot). To enable sorting of these cards, I added an icon next to each column title. My goal is to allow users to select sorting ...

What steps can I take to guarantee that my grid always accommodates its child without being too small?

My current setup involves utilizing a grid layout to arrange elements in the z-direction. However, I have encountered an issue where a child element extends beyond the boundaries of the grid element: #z-stack { display: grid; border: 5px solid ...

Employ the power of AJAX to selectively display or conceal a specific group of images

Have you ever thought about showcasing a large number of images on a non-CMS website? Say you have 50 images that can't all be displayed at once. One idea is to display the first 15, then allow users to click "Next" to reveal the next batch of 15, and ...

When running `node compile.js`, no combined CSS file is being created

I have finally mastered the art of setting up and executing the "node compile.js" file in the claro theme folder to compile each *.less file into its corresponding *.css file. However, I noticed that the old claro.css file remains unchanged. Is this the in ...

What is the best way to coordinate text and photos within Bootstrap?

Currently, I am working on a bootstrap website that features a slideshow with 3 photos. The jQuery function responsible for this is as follows: $(function () { $.vegas('slideshow', { backgrounds: [{ src: 'img/ph1.jpg ...

display the designated image as a priority

I am designing a loading screen for my website that includes the loading of multiple images, scripts, and other elements. While the HTML and CSS part is working well, I need to ensure that the "loading..." image is loaded before anything else on the page. ...

The contact form is encroaching on the footer

The issue arises when the contact form overlaps with the footer. When testing the code on Codepen, the styles are correctly linked and working for everything except the contact form. I have attempted adjusting the padding, bottom position, etc., but nothin ...

"Toggling a switch alters the appearance following the submission of a form

Recently, I incorporated a switch toggle into my form to help filter products. I followed this guide. However, after submitting the form, the page reloads using ajax and the switch toggles back to its initial style before being toggled again. What could be ...

Rendering dynamic HTML content using EJS

I've created a blog application using Express and MongoDB, with EJS for rendering the data. My issue lies in the styling of the content to resemble a paragraph: <div class="show-post__content"> <%= post.body %> </div> The po ...

What is the best way to retrieve the values from the labels for two separate buttons?

I designed a pair of buttons with a single label below. Both buttons acted as standalone entities. <label for="buttons" class ="val">0</label> <input class="btn btn-primary button1" type="button" ...

create a recurring design wallpaper within the TinyMCE editor

One of my functions alters the background of the tinymce editor. However, I am interested in having a wallpaper repeat in a similar fashion to background-repeat: repeat; in CSS. How can I achieve this? Here is the function: function SettinymceImage(bg_i ...

Ways to adjust Safari printing margins using CSS to achieve borderless printing

I am struggling to eliminate margins when printing a webpage to PDF in Safari. Despite setting the page size to 'A4 borderless' in the print dialogue, Safari on OSX continues to add extra margins around my HTML. Enabling 'print backgrounds&a ...

Make the <textarea> occupy the entire available space

How can I make a <textarea> occupy all available space within a <td> element? Upon clicking inside the table cell, the <textarea> should display with precisely the same dimensions as the cell itself, resembling an Excel spreadsheet. I h ...

Tips for creating a dynamic design for an Inputfield when it is in use

Imagine if the background color is red and I want the input text field to be red as well. However, when you click inside the input field to type, it should turn into a regular text field. And of course, when you are not actively typing in the input field, ...

Scrolling with jQuery to create a fixed navigation bar

I'm having an issue with my navbar on my website. I used CSS and jQuery to keep it fixed at the top, but now when I click on a menu item, it doesn't scroll to that section of the page. Can anyone help me troubleshoot this problem? ...

In JavaScript, alert a message once all images have been clicked

I'm encountering a small issue with my javascript code. I am developing a game for a school project where the objective is to click (remove) fish using a fishing rod. However, the game does not have an end condition set up, so players cannot win. Belo ...

Transforming Text On Hover Using CSS, as well as Customizing the Style

I've been struggling with this issue for quite some time now. Despite scouring the first page of Google search results for "css change text on hover," I have not been able to find a solution. Inside a div, I have text that is styled and positioned us ...

Canvas ctx.drawImage() function not functioning properly

I've encountered an issue while trying to display images in a canvas using my rendering function. Here is the code snippet: function populateSquareImages(){ for(var i = 0, ii = squares.length; i < ii; i++) { if(squares[i].hasImage) { ...

Attempting to reach <p> from numerous web pages

Currently, I am working on a project where I need to extract text data from various websites. I have successfully managed to retrieve the text data using <p> tags. I would really appreciate any assistance with this task. Thank you! ...

The HTML canvas drawImage method overlays images when the source is modified

Trying to implement a scroll animation on my website, I came across a guide for creating an "Apple-like animation" using image sequences. Even though I'm new to Angular, I attempted to adapt the code to work with Angular. However, instead of animatin ...