Is there a way to eliminate the gap between two divs that are positioned one on top of the other vertically

Looking at the image, I need the div above the footer to be flush with it. I've tried various solutions and need help from someone with more experience. Here is the HTML and CSS code for reference. Illustration link

HTML and CSS

.content{
    margin:0;
    width: 100%;
    /*padding-top:30px;*/
    /*padding-left: 3px;*/
    /*padding-right: 0px;*/
    /*padding-bottom: 60px;*/
    font-family: 'Lato', sans-serif;
}

#footer{
    height:200px;
    /*width:100%;*/
    background:#1c1c1c;
    text-align: center;
    padding-top:69px;
    padding-bottom: 69px;
}

.post_date{
    padding:20px 0;
    border-top: 1px solid #dbdbdb;
    border-bottom: 1px solid #dbdbdb;
    width:100%;
    color:#dbdbdb;
}

.card{
    width:100%;
    height:379.6px;
    /*background: red;*/
    /*padding-left: 2px;*/
}

/*Card 6 properties*/
#c6{
    background: #9b59b6;
}

#c6 h3{
    color:white;
}
.b6,.s6{
    color:white;
}
/**********/

img{
    width:100%;
    margin: 0px;
}
<section id="section-6" class="grid">
    <div class="images img6">
    <img src="images/pic12.jpg">
    </div>
    <div class="card" id="c6">
    <div class="content">
    <header>
    <h3>Magna porta aliguam</h3>
    </header>
    <p class="post_date"> 3 days ago by <span class="s6">John Doe</span></p>
    <p>
    Nullam posuere erat vel placerat rutrum. Praesent ac consectetur dui, et congue quam. Donec aliquam lacinia condimentum. Integer porta massa sapien, commodo sodales diam suscipit vitae. Aliquam quis felis sed urna semper semper. Phasellus eu scelerisque mi. Vivamus aliquam nisl libero, sit amet scelerisque ligula laoreet vel.
    </p>
    <button class="btn b6"> Read More</button>
    </div>
    </div>
    </section>

<footer id="footer">

<div id="social_media">
<ul>
<li><i class="fab fa-twitter"></i></li>
<li><i class="fab fa-facebook-f"></i></li>
<li><i class="fab fa-instagram"></i></li>
</ul>
</div>

<div class="copyright">
@Untitled Design. <a href="#">Templated:</a> Images: <a href="#"> Unsplash</a>
</div>
</footer>

</main>

</body>
</html>

Answer №1

The issue stems from the margin on the h3 element within your header. You can eliminate this space by applying the following CSS snippet.

header h3 {margin-top: 0px;}

I trust this solution will be beneficial to you :)

Answer №3

How about adding margin-top: -23px to the class card? Alternatively, you can also add margin-bottom: -23px to the img tag

.card{
    width:100%;
    height:379.6px;
    margin-top: -23px;
   }

Or

.images.img6 {
margin-bottom: -23px;
}

I hope this suggestion helps ^^ You can view the changes here https://jsfiddle.net/ajz9gj5n/

I also found another solution at https://jsfiddle.net/ajz9gj5n/1/

In the CSS, I added

.images.img6 {
  display: grid;
}

And I rearranged the HTML from

<section id="section-6" class="grid">
    <div class="images img6">
        <img src="https://i.ytimg.com/vi/SfLV8hD7zX4/maxresdefault.jpg">
    </div>
    <div class="card" id="c6">
        <div class="content">
            <header>
                <h3>Magna porta aliguam</h3>
            </header>
        <p class="post_date"> 3 days ago by <span class="s6">John Doe</span></p>
        <p>
        Nullam posuere erat vel placerat rutrum. Praesent ac consectetur dui, et congue quam. Donec aliquam lacinia condimentum. Integer porta massa sapien, commodo sodales diam suscipit vitae. Aliquam quis felis sed urna semper semper. Phasellus eu scelerisque mi. Vivamus aliquam nisl libero, sit amet scelerisque ligula laoreet vel.
        </p>
        <button class="btn b6"> Read More</button>
        </div>
    </div>
</section>

to

<section id="section-6" class="grid">
     <div class="images img6">
        <img src="https://i.ytimg.com/vi/SfLV8hD7zX4/maxresdefault.jpg">
        <div class="card" id="c6">
            <div class="content">
                <header>
                    <h3>Magna porta aliguam</h3>
                </header>
                <p class="post_date"> 3 days ago by <span class="s6">John Doe</span></p>
                <p>
                Nullam posuere erat vel placerat rutrum. Praesent ac consectetur dui, et congue quam. Donec aliquam lacinia condimentum. Integer porta massa sapien, commodo sodales diam suscipit vitae. Aliquam quis felis sed urna semper semper. Phasellus eu scelerisque mi. Vivamus aliquam nisl libero, sit amet scelerisque ligula laoreet vel.
                </p>
                <button class="btn b6"> Read More</button>
            </div>
        </div>
    </div>
</section>

I placed the div "card" inside the div "images img6"

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

Creating a custom progress bar using Javascript and Jquery

I developed a progress bar that is fully functional. Here is the HTML structure: <div class="progress"> <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style ...

How can I conceal text using css in specific situations without risking a penalty from search engines?

Currently, I'm developing an illustration tool that needs to be visually appealing to users, while also being accessible to screen readers and search engines. Below is the HTML code I'm working with: <span class="card">A new idea is presen ...

Is it possible to resize an inline SVG element without modifying the <svg> tag?

Utilizing a Ruby gem known as rqrcode, I am able to create a QR code in SVG format and send it as an API response. Within my frontend (Vue.js), I am faced with the task of displaying the SVG at a specific size. Currently, my code appears as follows, rende ...

Utilizing Jquery to locate a link inside a Div and displaying it as specified in the HTML

Looking for a solution to make div elements clickable as links? The usual methods involving window.location or window.open may not be suitable if you have numerous divs with predefined targets. If you're not well-versed in Javascript, finding the righ ...

When XML is accessed through an iframe, it is interpreted as HTML

In my endeavor to display an xml file within an HTML page using an iframe and altering the content through jQuery by manipulating the source attribute, I encountered a curious issue. When I viewed the xml file directly in my browser (Firefox/Chrome/IE8), i ...

What could be the reason for the function providing the value of just the initial input?

Why am I only getting "White" when I click on the colors? I can't seem to get any other values to appear on the screen. I'm confused about what mistake I might be making here. var x = document.getElementById("mySelect").value; function myFunc ...

js The correct value is not being set to the div's style.top

function gamestart(){ var gr; var gr = true; console.log(gr==true); if(gr == true){ console.log("we have activated pointer key detection dear Mr.ketsebaot") document.onkeydown = checkk; } } function checkk(e){ cons ...

How to keep jQuery horizontal submenu open when clicking on the menu

Seeking assistance with a menu issue. I have a horizontal menu with subitems that display when clicked, but having trouble with the submenu behavior. When clicking on a submenu item, I want it to remain open and show the related items underneath it. For ex ...

Singularize button/solo in the center

How can I make this button align perfectly center on both PC and Mobile as a container? I have attempted the following CSS and HTML code: <section id="jour"> <div class="container"> <button class="btn1">Jeudi 12</button> ...

Using the onreadystatechange method is the preferred way to activate a XMLHttpRequest, as I am unable to trigger it using other methods

I have a table in my HTML that contains names, and I want to implement a feature where clicking on a name will trigger an 'Alert' popup with additional details about the person. To achieve this, I am planning to use XMLHttpRequest to send the nam ...

Responsive SmoothSlider

Need help fixing the responsive breadcrumbs in my slick slider. The slick-content-slider is taking a strange height and I want to ensure that every div remains on the same line. Thank you in advance! $('.slick-content-slider').slick({ slides ...

JavaScript and Angular are used to activate form validation

Update: If I want to fill out the AngularJS Forms using the following code snippet: document.getElementById("username").value = "ZSAdmin" document.getElementById("password").value = "SuperSecure101" How can I trigger the AngularJS Form validation befo ...

Adjusting the size of a canvas element based on changes in the browser window dimensions

I'm currently working on developing a website layout in React that consists of: A top bar A right side bar A canvas element that occupies the remainder of the screen space These elements need to adjust to the browser window size changes while fillin ...

CSS problem: HTML element moving to the right upon clicking

Currently, I am utilizing a jQuery popup to present additional information to users. The setup involves having a link on the page that triggers the popup to appear from the top. The popup script being used is sourced from CodePen. However, an issue arises ...

Using JavaScript to apply styling on images with overlays

I am currently facing an issue with placing an overlay on top of a background image. Despite my efforts, I am unable to get the background color to appear on top of the image. Any helpful suggestions on how to resolve this would be greatly appreciated. M ...

Differentiating card heights on hover in bootstrap can be achieved by adjusting the CSS properties specifically for each card

I'm currently working with bootstrap cards and have added hover effects to them. However, I'm facing an issue where on larger devices, hovering over one card enlarges all the other cards as well. This problem doesn't occur on smaller devices ...

Utilizing data binding in AngularJS upon choosing an item from a drop-down menu

I'm new to AngularJS and would appreciate any help on how to accomplish the following task: When I select an option from a dropdown list, I want the relevant information to be displayed in readonly fields. Here is an attachment for reference: https:// ...

The ng-View feature appears to be malfunctioning within AngularJS

I'm extremely new to AngularJS and am having trouble with ng-view. Here is the code from AngularFormsApp.js: var angularFormsApp = angular.module('angularFormsApp', ["ngRoute"]); angularFormsApp.config(function ($routeProvider) { $routeP ...

What could be causing the excess space in the right corner of my website's mobile version?

After creating a practice website deployed on Vercel, I ensured it was responsive by incorporating breakpoints for different screen sizes. However, upon viewing the dashboard page on my mobile device, I noticed some unwanted extra space in the top right co ...

Updating checkbox Icon in Yii2

Is there a way to customize the checkbox icon when it is checked in Yii2? Currently, I am adding a checkbox inside a div along with an icon: <i class="fa fa-check-circle icon-check-circle"></i>. However, the checkbox shows a default check symbo ...