Issue
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">
<style>
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;
}
</style>
</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>
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>
normally i will do like this:
body {
margin: 0;
padding: 0;
font-family: "Open+Sans", sans-serif;
}
.nav {
float: right;
text-align: left;
margin: 0;
position: relative;
}
/* new css here */
.nav-bar {
border-bottom: 2px solid #0c133c;
}
.clearfix::after {
content: '';
display: block;
clear: both;
}
/* new css here */
.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;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Navbar</title>
<link rel="stylesheet" href="styles.css"
</head>
<body>
<!-- add a father element -->
<div class="nav-bar clearfix">
<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>
</ul>
</div>
</body>
</html>
Answered By - Dou
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.