Steps for adding a ::after border to a div

Looking for a way to create a border line separator between the top and bottom sections? I've been struggling with this task, but I have managed to make progress by adding a white line. However, I'm facing an issue where the container's width does not cover the entire footer-border section as intended. Whenever I try setting it to 100%, it extends beyond the page's right-hand side. Take a look at the image below to see what I mean:

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

<footer>
    <section class="footer-top">
        <div class="container">
            <div class="row footer-border">


                    <div class="col-md-3 footer-top-one">
                        <a title="Contrast" class="footer-logo" href="<?php echo site_url() ?>"><img src="<?php echo esc_url( get_template_directory_uri() )?>/assets/img/contrast-logo-white-horizontal.svg"></a>
                        <p>We are a specialist eCommerce digital marketing agency. As our name suggests, we do things differently.</p>
                        <a target="_blank" href="https://www.facebook.com/contrast.digital/"><i class="fab fa-facebook-f"></i></a>
                        <a target="_blank" href="https://twitter.com/contrasttalk"><i class="fab fa-twitter"></i></a>
                        <a target="_blank" href="https://www.linkedin.com/company/contrastuk/"><i class="fab fa-linkedin-in"></i></a>
                        <a target="_blank" href="https://www.instagram.com/contrast.digital/"><i class="fab fa-instagram"></i></a>
                        <a target="_blank" href="https://www.youtube.com/channel/UCb4cTmxtsT-Wdcdi4mmsx9Q?view_as=subscriber"><i class="fab fa-youtube"></i></a>
                    </div>

                    <div class="col-md-2 footer-top-three">
                        <h4>Discover</h4>
                        <nav class="navbar navbar-light bg-lignt navbar-expand-md flex-md-row nav-header" role="navigation">       
                        <?php
                        wp_nav_menu( array(
                            'theme_location'    => 'footer_discover',
                            'depth'             => 2,
                            'container'         => 'div',
                            'container_id'      => 'footer-top-nav',
                            'menu_class'        => 'nav navbar-nav ml-auto',
                            'fallback_cb'       => 'WP_Bootstrap_Navwalker::fallback',
                            'walker'            => new WP_Bootstrap_Navwalker()
                        ) );
                        ?>
                        </nav>
                    </div>

                    <div class="col-md-2 footer-top-two">
                        <h4>Derby</h4>
                        <p>St George Court, Alfreton Rd</p>
                        <p>Derby</p>
                        <p>DE21 4AP</p>
                        <b><a href="tel:+01332300583"><p class="footer-phone-number">01332 300 583</p></a></b>
                        <b><a href="/contrast/contact/" target="_top"><p>Contact Our Team</p></a></b>
                    </div>

                    <div class="col-md-2 footer-top-two">
                        <h4>Nottingham</h4>
                        <p>26-30 Stoney St</p>
                        <p>Nottingham</p>
                        <p>NG1 1LL</p>
                        <b><a href="tel:+01332300583"><p class="footer-phone-number">01332 300 583</p></a></b>
                        <b><a href="/contrast/contact/" target="_top"><p>Contact Our Team</p></a></b>
                    </div>

                    <div class="col-md-3 footer-top-five">
                        <h4>Growth Strategies</h4>
                        <p>We’ll send you growth strategies you can implement yourself to give your eCommerce business the competitive edge it deserves.</p>
                        <a class="clear footer-cta" title="Send Me Growth Strategies" href="/contrast/newsletter/"><button>Send Me Growth Strategies</button></a>
                    </div>
            </div>
        </div>
    </section>
    <section class="footer-bottom">
        <div class="cotainer">
            <div class="row justify-content-between">
                <div class="col-lg-auto">
                  <p>Company Reg No. 11332749</p>
                </div>
                <div class="col-lg-auto">
                  <p>Copyright &copy; <?php echo date("Y"); ?> Contrast Digital Ltd</p>
                </div>
                <div class="col-lg-auto p0">
                    <nav class="navbar navbar-light bg-lignt navbar-expand-md flex-md-row nav-header" role="navigation">
                    <?php
                    wp_nav_menu( array(
                        'theme_location'    => 'footer_privacy',
                        'depth'             => 2,
                        'container'         => 'div',
                        'container_id'      => 'footer-privacy-nav',
                        'menu_class'        => 'nav navbar-nav ml-auto',
                        'fallback_cb'       => 'WP_Bootstrap_Navwalker::fallback',
                        'walker'            => new WP_Bootstrap_Navwalker()
                    ) );
                    ?>
                    </nav>
                </div>
            </div>
        </div>
    </section>
</footer>

<!-- CSS Styling -->
footer {
    background: $black;
    color: $white;
    margin: 30px;
    margin-top: 30px;

    section.footer-top {
        padding: 40px 0;

        .footer-border::before {
            content:'';
            position: absolute;
            border-bottom: 1px solid $white;
            width: 100%;
        }
        
        // Other styling properties...

    }

    section.footer-bottom {
        padding: 40px 0;

        p {
            font-size: 0.667em;
            color: $white;
            text-align: center;
            margin-bottom: 0;
        }
    }

    // More CSS styling...
}

Answer №1

Give this a try

footer{
  width:100%;
  overflow:hidden;
  display:inline-block;
   border:1px solid #000000;
}

.container{
 margin: 20px; 
 
}
.footer-border{
 height:100px;
 position:relative;
}
.footer-border:after{
  position :absolute;
  left:0;
  right:0;
  bottom:0;
  content:"";
  height:1px;
  width:100%;
  background-color:#ff0000;
}
.footer-border:before{
  position :absolute;
  left:0;
  right:0;
  top:0;
  content:"";
  height:1px;
  width:100%;
  background-color:#ff0000;
}
<footer>
  <div class="container">
    <div class="footer-border">

    </div>
  </div>
</footer>

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

Scrolling behavior in two columns with sticky positioning

Both columns have varying heights, with the left sometimes higher than the right. I want them to start scrolling down simultaneously, but when the shorter column's content ends, it should stick to the bottom of the viewport and "wait" until the taller ...

Adjust position of table row using jquery

I've been exploring ways to adjust the position of a table row using jQuery, and here's what I came up with: top_position = $("#table_id").offset().top; $("#table_id tr:nth-child(1)").offset().top = top_position; Despite my efforts, this code d ...

Horizontal navigation bar encroaching on slideshow graphics

I'm encountering difficulties aligning the horizontal menu below the image slider. When I have just an image without the slider, the menu aligns properly (vertically), but as soon as I introduce the code for the slider, the menu moves to the top and d ...

Is it possible to update table cell content depending on selected option?

Displayed here is the select block: <form> <select id="select"> <option disabled selected value="choose"> CHOOSE </option> <option value="i2g" id="i ...

Is the 3D cube spinning with a slight perspective glitch?

I've successfully created a spinning cube using html and css. However, I'm facing an issue where pressing the up and down arrow keys causes the cube to rotate in a larger space rather than around its center. I've attempted using margin: 0 a ...

Why my attempts to alter numerous CSS elements using JQuery are failing?

Here's the code snippet I'm working with: var showThis = $(this).attr('id'); // div0, div1, div2 etc. $('#' + showThis).attr('style', 'background-color: #063 !important, height: 520px'); I am trying to mo ...

Create a full-width slider using Materialize CSS framework

When using materializecss to create a slider, I encountered an issue where the image is full width but not full height, causing scrollbars to appear. What changes can I make to ensure the slider fills out my screen without any scrollbars? Additionally, I ...

One div on Chrome for Mac is experiencing an issue with applying the background image

I currently have a website hosted on GitHub pages at this link: When viewing the site on Windows Chrome, the bottom div containing the filtering buttons blends seamlessly with the dark grey background set in the wrapper div. However, when viewed on Mac Ch ...

Utilizing the React.js Bootstrap grid system

I've been diving into React, but I'm facing an issue with the bootstrap grid/reactstrap. Instead of getting horizontal columns as expected when using the grid system, I seem to be stuck with a vertical layout. Film.js import React from "react"; ...

I am encountering issues with setting a background image in Bootstrap 3.1.1 while trying to achieve a par

I'm struggling to add a background image to my bootstrap site. I'm attempting to create a parallax site using stellar.js, and while the site is functional with text on each slide and correct scrolling links, the images just won't load. Despi ...

Problem with transitions not working properly in Vue.js.The issue

Experiencing an issue with the Vue.js transition feature. Check out this link for reference. When the transition enters, it works smoothly, but when transitioning out, it's not functioning properly. File: genetic.vue <transition name="slide-f ...

Choose the label by utilizing the CSS selector

I am currently using CSS to create tabs with radio buttons. However, I am struggling to figure out how to select the corresponding <label> for the radio button. To keep the labels separate from the content and display them as tabs, I have structured ...

Enhance Bootstrap typeahead to accommodate multiple values

I have a basic typeahead setup for searching city names. However, upon selecting a city, I also need to retrieve its latitude and longitude in order to send that data to the backend. $('.typeahead').typeahead({ minLength : 3, source : ...

Guide to implementing multiple CSS files in Django template inheritance

Seeking a solution for incorporating multiple CSS files for different templates using Django template inheritance. Currently, I have extended my base.html template with another app's template. Now, I want to use separate CSS files for each app's ...

Responsive Bootstrap 4 Login Form with customized top height

This login form was created using Bootstrap 4, starting with a preset that I then customized to fit my needs. As someone new to Bootstrap and CSS, I struggled with making the form responsive. When resizing the window, the top portion gets cut off and is no ...

CSS/React JS: I wish for the input fields to maintain focus even after entering values

I'm working with a confirmation code that is made up of 6 digits. I've noticed that when I click on an input field, it becomes focused and underlined in blue. However, as soon as I start typing in the next input field, the blue underline disappe ...

Vertically aligning text in separate div containers

Currently, part of my dashboard page is styled using the Bulma CSS framework. One feature is a 'Widgets' feature with three large containers displaying key facts such as the number of sales, new customers, etc. The issue I'm facing is that ...

What could be causing the multiselect to fail to update?

Currently, I am having an issue with bsMultiselect and bootstrap 5. Despite having all the required scripts in place, the multiselect element only updates after a page reload. The goal is to have the multiselect updated when an option in another select e ...

Styling in CSS is being applied to a button element within a React component,

Having trouble with a button styled with the className 'actions' The button displays the CSS styling from '.actions', but not '.actions button'. Both should be applied. This code snippet works for all elements ...

Guide on Applying a Dynamic Color in VueJs 3 Composition API/Vuetify Using CSS

Currently, my project utilizes Vue 3 with the composition API and Vuetify for the UI. I am looking to utilize a color that is already defined in a Vuetify theme variable within my CSS, similar to how I have done it previously in JavaScript. Although I at ...