Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to create a line in HTML

I’m trying to create a horizontal line underneath my nav bar, the only problem is that the line breaks. How do I get the line to go all the way across the page? I tried using border and using hr is the closest I can get to what I want but I need it to go all the way across.

HTML:

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Navbar</title>
    <link rel="stylesheet" href="styles.css"
    

</head>

<body>

<ul class="nav justify-content-end">
  <li class="nav-item">
    <a class="nav-link active" aria-current="page" href="#">Get a Quote</a>
  </li>
<li class="nav-item">
   <a class="nav-link active"aria-current="page" href="#">Contact Us</a>
  </li>
  <li class="nav-item">
   <a class="nav-link active"aria-current="page" href="#">Sign In</a>
  </li>
 
<hr class="solid">  
 
</ul>

</body>
</html>

CSS:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

body {
   margin:0;
   padding: 0;
   font-family: "Open+Sans", sans-serif;
}


#nav {
    background-color: #fff; 
    color: white;
    width: 100%;

}
.nav {
  float: right;
    text-align: left;
  margin: 0;
}
.nav > li {                                                             
    display:Inline-block;
    padding: 20px 50px 10px 9px;                              
}

 .nav > li a {                                               
     text-decoration: none;
     color: #0C133C;
     font-size: 18px;
  
 }
hr.solid {
  border-top: 2px solid #0C133C;
}

Image

>Solution :

well. wish add this css in your styles.css and remove the hr tag can solve ur problem

.nav {
  float: right;
  text-align: left;
  margin: 0;
  position: relative;
}
.nav::after{
    content: '';
    height: 2px;
    position: absolute;
    display: block;
    right: 0;
    width: 100vw;
    bottom: 2px;
    background-color: #000;
}
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Navbar</title>
    <link rel="stylesheet" href="styles.css"
  </head>

  <body>
    <ul class="nav justify-content-end">
      <li class="nav-item">
        <a class="nav-link active" aria-current="page" href="#">Get a Quote</a>
      </li>
      <li class="nav-item">
        <a class="nav-link active" aria-current="page" href="#">Contact Us</a>
      </li>
      <li class="nav-item">
        <a class="nav-link active" aria-current="page" href="#">Sign In</a>
      </li>

      <!-- <hr class="solid" /> -->
    </ul>
  </body>
</html>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading