What is the best way to insert a horizontal line in Bootstrap 4 using HTML and CSS?

I'm looking to incorporate a small horizontal line similar to the one shown on this page. I attempted to use the <hr\> tag, but it didn't produce the desired result. Are there alternative methods for adding this line? Below is an outline of what I've tried so far to create the line, yet I haven't been successful in achieving it. Any assistance in creating the line would be greatly appreciated. Thank you.

.second-bg-cover{
    background-image: linear-gradient(rgba(0, 0, 0, 0.7),rgba(0, 0, 0, 0.5)) ,url(../img/state1.jpg);
    width: 100%;
    height: 320px;
    background-repeat: no-repeat;
    position: relative;
    z-index: -1;
  }

  .second-cover-heading {
    position: absolute;
    z-index: 1;
    padding: 60px 0;
    color: var(--white);
  }

  .second-cover-photo-section h1{
    font-family: 'Raleway',sans-serif;
    font-weight: 400;
  }
  .second-cover-download{
    background: transparent;
    color: white;
    padding: 8px 18px;
    border-color: var(--white);
    position: relative;
    z-index: 2;

  }
  .second-cover-download{
    margin-left:580px;
    margin-top: 25px;
  }
<div class="row">
  <div class="col-md-12">
    <div class="second-bg-cover"></div>
  </div>
  <div class="col-md-12 second-cover-heading">
    <h1 class="text-center">STYLISH AXURE DESIGN</h1>
    <hr style="width:80px;height:2px;text-align:left;margin-left:660px;border: 1.5px solid white; color: white;">
    <p class="text-center mt-4">Use the selections you need, remove the lines you don't need.Create gorgeous prototypes faster than ever!
    </p>
    <div class="second-cover-download">
      <button class="second-cover-download ms-5" type="button">Download</button>
    </div>
  </div>
</div>

Answer №1

To add a stylish underline using the ::after pseudo-element, follow these steps:

HTML:

<h1 class="text-center with_line">BEAUTIFUL WEB DESIGN</h1>       

CSS:

.with_line::after{
  content: "";
  height: 3px;
  width: 120px;
  background: blue;
  display: block;
  margin: 0 auto;
  margin-top: 10px;
}

Check out the live example on JSFiddle: https://jsfiddle.net/8y19sucm/

Answer №2

If you want to create a horizontal line on your webpage, you can utilize the hr tag or define a custom class named "spacer" for more flexibility in designing the line. Here's an example:

  .spacer{
            width:100%;
            border:2px solid rgba(0,0,0,0.2);
            margin:0;
            box-sizing: border-box;
  }
  .myContainer{
            width:80%;
            margin-left:auto;
            margin-right:auto;
  }
  <div class="myContainer">
        Lorem ipsum dolor sit amet...
        <div class="spacer"></div>
  </div>

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

What is the best way to save a PDF from within a frame using JavaScript and an HTML5 <embed> tag?

I'm looking for assistance with a script for my website that dynamically generates a PDF after the user makes selections in one of the frames. The website uses the HTML5 tag to display the PDF file. Can anyone provide guidance on a script that can: ...

unable to record the input value in jquery

Snippet for HTML code: <div id="Background"> <input id="search-Bar" type="text"> <button id="SearchButton">Search</button> </div> var name = $("#search-Bar").val(); $("#SearchButton").on("click", function() { co ...

Creating Tab-Focused Accessibility in HTML Fragment (Modal Window)

I'm currently working on an Angular App with a custom Modal Dialog implementation. I'm trying to figure out how to restrict tabbing to just the elements within the Modal, rather than allowing users to tab through everything in the background. I ...

Tips for creating a single rolling scroll over multiple rows in a grid layout

I successfully implemented a grid layout for displaying four book images in a row with CSS, including responsive overflow. However, the challenge lies in ensuring that only one row scrolls at a time while allowing other rows to scroll simultaneously when o ...

Another query has arisen about the html5 dtd/schema

How can we validate HTML5 documents for syntax accuracy and structural soundness if there is no DTD or schema? It's crucial for our industry to have a reliable method of ensuring validity. The W3C's online validation tool is helpful for individua ...

Allow the <a> tag to open separate URLs on different pages

My goal was to have the <a> tag open two URLs simultaneously. I tried the following: Using only HTML <a href="URL1" target="_blank" onclick="window.open('URL2');">text</a> While this method did wo ...

The presence of absolute positioned elements is causing the appearance of a horizontal scrollbar

On my webshop's categoria page, I have implemented sliders to filter products based on price ranges. The issue arises when viewing the site on mobile devices, as a horizontal scrollbar appears due to the absolute positioning of these sliders and thei ...

Limitations on Embedding Videos with YouTube Data API

I have been using the Youtube Data API to search for videos, but I am encountering an issue with restricted content appearing in the results. Specifically, music videos from Vevo are showing up even though I only want videos that can be embedded or placed ...

Tips for creating a flexbox layout that is responsive to different screen

Currently, I am using flex to ensure that the two inner div elements have the same height. However, the design is not responsive as it appears perfectly in a full-width window but gets squeezed on mobile devices. Is there a solution to this issue? Are th ...

Could someone shed some light on why hjk fails to print whenever I click?

Why is the code not printing 'hgk' every time I click? The debounce function should run and print 'hgk' each time the button is clicked. Can someone please explain why this is not happening? const debounce=(fn,delay)=>{ ...

Programmatically setting focus in Ionic

In my Ionic and Angular component, I am attempting to programmatically set focus after the page has loaded. Here is the code: item.component.html: <ion-row> <ion-col col-5> <ion-item > <ion-label&g ...

Menu Toggle with Bootstrap 3

I have implemented two Bootstrap 3 navigation menus on a single page. One menu works fine when the toggle button is activated for responsiveness, but the other one doesn't work as expected. How can I resolve this issue? Below are the code snippets fo ...

When using HTML5 input type number with 16 or more digits, Chrome automatically replaces any extra digits with zeroes

Has anyone else encountered an issue with Chrome related to using the input type number when the number of digits exceeds 16? I've noticed that in my case, any numbers beyond the 16th digit are automatically replaced with a zero when the field loses f ...

Find the element that contains a specific substring in its value using JavaScript

I am trying to find a way to count how many input fields with the class name "text" contain a specific value. document.getElementById('c_files').getElementsByClassName('text').length; Currently, this code counts all textboxes with the ...

Mistake made by the author while using the Google Structured Data Test

While reviewing my website, I encountered an error message stating: "Missing required hCard "author"" http://www.google.com/webmasters/tools/richsnippets?q=http%3A%2F%2Fwww.gamempire.it%2Fcastlestorm-ps-vita%2Frecensione%2F131419 Why is this happening? I ...

Interactive ajax and php dropdown menu

Hey there, I'm running into a small snag with my dynamic select feature, as mentioned in the title. I am aiming to achieve the following outcome: When a user selects an instrument from the first dropdown menu, the second dropdown menu labeled "Besetzu ...

What could be causing my slider to malfunction?

No errors are being returned by the console. Currently utilizing Unslider. The setup includes: <div class="slider"> <ul> <li><img src="img/one.jpg" alt=""></li> <li><img src="img/one.jpg" ...

Is there a reason why using margin:auto doesn't work for vertically centering items?

I'm having trouble understanding how margin auto functions. In the scenario I'm dealing with, I have a parent div and a child div nested within it, both with specified widths and heights. I attempted to use margin auto in order to center the inne ...

Adding a sibling inline can be accomplished by simply using the "+"

$("#sibling").prepend("#sibling2") <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="sibling">First sibling</div> <div>Another component</div> <div id="sibling2">Seco ...

Increase the height of the parent div and adjust the height of the other child div to match the height of the larger child div

I currently have a setup with four divs on my asp.net page: div7_1 (parent), div4_1, div11_1, and div6_1 as child divs. Here is how it looks: HTML <div id="div7_1"> <div id="div4_1"> </div> <div id="div ...