Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

Want to create a frame for a navbar

Edrol97

Silver Coder
I want to create a framing for a navbar on a particular page of my site similar to the one below. Currently the code I have is as follows:
HTML:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="Grauniad.css" />
    <link rel="stylesheet" href="mainstyle.css" />
    <title>Grauniad</title>
  </head>
  <body>
    <div class="topnav">
      <a href="Hi.html"
        >Hello and welcome to another news site you didn't ask for!</a
      >
    </div>
    <header class="navbar">
      <div class="logo">
        <img
          style="float: right"
          src="img/background/The Grauniad logo.png"
          width="20%"
        />
      </div>
      <nav>
        <div class="box">
          <a class="Home" href="Hi.html">Home</a><a>|</a>
          <a href="about_me.html">About</a><a>|</a> <a href="Art.html">Art</a
          ><a>|</a> <a href="cv.html">Work</a><a>|</a>
          <a href="Games.html">Play</a><a>|</a>
        </div>
      </nav>
    </header>
  </body>
</html>
CSS:
body {
  width: 100%;
  height: 100%;
  cursor: url(img/background/cursors/Mouse%20cursor);
}
@font-face {
  font-family: Guardian;
  src: url(Fonts/Guardian-Egyp-Web-Regular.ttf);
}
.navbar {
  background-color: #062962;
  width: 100%;
  height: 150px;
  padding-left: 2%;
}
.navbar a {
  color: white;
  font-family: Guardian;
  font-weight: 900;
  font-size: 5dvh;
  padding: 20px;
  float: left;
}
.navbar .Home a {
  padding-left: 40px;
}
.topnav {
  background-color: #0b1e47;
  width: 100%;
  top: 0%;
}
.topnav a {
  color: white;
  font-family: Guardian;
  font-size: 4dvh;
  font-weight: 900;
}
.box {
  width: 80%;
  height: 80%;
  border: 3px white;
  top: 0;
  right: 0;
  background-color: #062962;
}
 

Attachments

  • Screenshot 2024-10-24 at 19.39.53.png
    Screenshot 2024-10-24 at 19.39.53.png
    72.1 KB · Views: 3
I want to create a framing for a navbar on a particular page of my site similar to the one below. Currently the code I have is as follows:
HTML:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="Grauniad.css" />
    <link rel="stylesheet" href="mainstyle.css" />
    <title>Grauniad</title>
  </head>
  <body>
    <div class="topnav">
      <a href="Hi.html"
        >Hello and welcome to another news site you didn't ask for!</a
      >
    </div>
    <header class="navbar">
      <div class="logo">
        <img
          style="float: right"
          src="img/background/The Grauniad logo.png"
          width="20%"
        />
      </div>
      <nav>
        <div class="box">
          <a class="Home" href="Hi.html">Home</a><a>|</a>
          <a href="about_me.html">About</a><a>|</a> <a href="Art.html">Art</a
          ><a>|</a> <a href="cv.html">Work</a><a>|</a>
          <a href="Games.html">Play</a><a>|</a>
        </div>
      </nav>
    </header>
  </body>
</html>
CSS:
body {
  width: 100%;
  height: 100%;
  cursor: url(img/background/cursors/Mouse%20cursor);
}
@font-face {
  font-family: Guardian;
  src: url(Fonts/Guardian-Egyp-Web-Regular.ttf);
}
.navbar {
  background-color: #062962;
  width: 100%;
  height: 150px;
  padding-left: 2%;
}
.navbar a {
  color: white;
  font-family: Guardian;
  font-weight: 900;
  font-size: 5dvh;
  padding: 20px;
  float: left;
}
.navbar .Home a {
  padding-left: 40px;
}
.topnav {
  background-color: #0b1e47;
  width: 100%;
  top: 0%;
}
.topnav a {
  color: white;
  font-family: Guardian;
  font-size: 4dvh;
  font-weight: 900;
}
.box {
  width: 80%;
  height: 80%;
  border: 3px white;
  top: 0;
  right: 0;
  background-color: #062962;
}

I'd suggest using a UL for your nav items and then you can apply borders to the LI elements. Of course you'll need to style the UL to be without bullets and horizontal. Pad the A elements to create your rectangular click areas.


HTML:
<nav>
        <div class="box">
            <ul>
                <li><a class="Home" href="Hi.html">Home</a></li>
                <li><a href="Art.html">Art</a></li>
                <li><a href="cv.html">Work</a></li>
                <li><a href="Games.html">Play</a></li>
            </ul>
        </div>
    </nav>

CSS:
ul{
            border-bottom: 1px solid black;
            display: flex;
            justify-content: flex-start;
            align-items: flex-end;
            list-style-type: none;
            margin: 0;
            padding: 0;

            li:not(:last-of-type){
                border-right: 1px solid black;
            }

            li a{
                display: block;
                padding: 5px 10px;
                text-decoration: none;
            }
        }

Adjust as needed
 
Back
Top Bottom