What's new

Welcome to the forum 👋, Visitor

To access the forum content and all our services, you must register or log in to the forum. Becoming a member of the forum is completely free.

Center the navbar text

Lariekoekebroek

New member
Joined
Jan 3, 2021
Messages
1
Reaction score
0
HTML Coins
0
Hey everybody!
I am working on a website with a fixed navbar on top.
The text starts on de left side of the page.
But i want it to be centered.
This is de html i have.
Can someone please help me out? Thank you!

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
margin-left: 0px;
font-size: 20px;
font-family: inherit;
background-color: white

}

#navbar {
overflow: hidden;
text-align: center;
background-color: rgba(0, 0, 0, 0.3);
padding-left: 250px
margin-left: 0px;
margin-right: 0px;
}

#navbar a {
float: left;
display: block;
color: white;
background-color:
text-align: center;
padding: 14px 15px;
text-decoration: none;
font-size: 20px;
}

.dropdown {
float: left;
overflow: hidden;
}

.dropdown .dropbtn {
font-size: 20px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}

#navbar a:hover, .dropdown:hover .dropbtn {
background-color: #A89100;
color: white;
text-align: center;

}

.dropdown-content {
display: none;
position: fixed;
background-color: rgba(0, 0, 0, 0.3);
width: 176px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}

.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}

.dropdown-content a:hover {
background-color: #ddd;
width: 176px;
}

.dropdown:hover .dropdown-content {
display: block;
}

.content {
padding: 60px;
text-align: center;

}

.sticky {
position: fixed;
top: 0;
width: 100%;
text-align: center;
}

.sticky + .content {
padding-top: 60px;
text-align: center;

}
</style>
</head>
<body>

<div id="navbar">
<text-align: center;>
<a class="active" href="#home">Home</a>
<a href="#boomwinkel">Adopteer een boom</a>
<a href="#boomwinkel">Webwinkel</a>
<a href="#overons">Over ons</a>
<div class="dropdown">
<button class="dropbtn">Verdere informatie
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a href="#diensten">Diensten</a>
<a href="#horeca">Horeca</a>
<a href="#gezondleven">Gezond leven</a>
</div>
</div>
<a href="#contacteer">Contacteer</a></text-align:>
</div>

<script>
window.onscroll = function() {myFunction()};

var navbar = document.getElementById("navbar");
var sticky = navbar.offsetTop;

function myFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky")
} else {
navbar.classList.remove("sticky");
}
}
</script>

</body>
</html>
 
Have you yet tried writing it into your HTML instead or an external CSS, mate?
 

Theme customization system

You can customize some areas of the forum theme from this menu.

  • Wide/Narrow view

    You can control a structure that you can use to use your theme wide or narrow.

    Grid view forum list

    You can control the layout of the forum list in a grid or ordinary listing style structure.

    Picture grid mode

    You can control the structure where you can open/close images in the grid forum list.

    Close sidebar

    You can get rid of the crowded view in the forum by closing the sidebar.

    Fixed sidebar

    You can make it more useful and easier to access by pinning the sidebar.

    Close radius

    You can use the radius at the corners of the blocks according to your taste by closing/opening it.

  • Choose the color combination that reflects your taste
    Background images
    Color gradient backgrounds
Back