Aleksandar Jeremic
Aleksandar Jeremic

Reputation: 19

Create navbar i have problem with floating my links is left but i want to be right

I want to create a simple navbar but I don't know what I am doing wrong. I want my links to be on the right, site logo on the left side.

My links are on the left side but I want to the right site I added float:right; but doesn't work.

* {
  margin: 0;
  padding: 0;
  border: 0;
  box-sizing: border-box;
}

a,
li,
ul {
  text-decoration: none;
  list-style-type: none;
}

.bg-dark {
  background-color: #000;
}

.gyaro-bar {
  position: relative;
  display: flex;
  width: 100%;
  height: 50px;
}

.gyaro-bar>a.gyaro-brand {
  display: inline-flex;
  font-size: 20px;
  color: red;
  align-items: center;
  justify-content: center;
  float: left;
  margin-left: 15px;
}

.gyaro-bar>ul.gyaro-bar-items {
  display: inline-flex;
  float: right;
}

.gyaro-bar>ul.gyaro-bar-items>li.gyaro-bar-links {}
<nav class="gyaro-bar bg-dark">
  <a href="index.php" class="gyaro-brand">
    GYARO
  </a>
  <ul class="gyaro-bar-items">
    <li class="">
      <a href="index.php" class="">
        Home
      </a>
    </li>
  </ul>
</nav>

Here codepen link

Upvotes: 2

Views: 29

Answers (1)

johannchopin
johannchopin

Reputation: 14844

Just use justify-content: space-between on the .gyaro-bar element:

* {
  margin: 0;
  padding: 0;
  border: 0;
  box-sizing: border-box;
}

a,
li,
ul {
  text-decoration: none;
  list-style-type: none;
}

.bg-dark {
  background-color: #000;
}

.gyaro-bar {
  position: relative;
  display: flex;
  justify-content: space-between;
  width: 100%;
  height: 50px;
}

.gyaro-bar>a.gyaro-brand {
  display: inline-flex;
  font-size: 20px;
  color: red;
  align-items: center;
  justify-content: center;
  float: left;
  margin-left: 15px;
}

.gyaro-bar>ul.gyaro-bar-items {
  display: inline-flex;
  float: right;
}

.gyaro-bar>ul.gyaro-bar-items>li.gyaro-bar-links {}
<nav class="gyaro-bar bg-dark">
  <a href="index.php" class="gyaro-brand">
    GYARO
  </a>
  <ul class="gyaro-bar-items">
    <li class="">
      <a href="index.php" class="">
        Home
      </a>
    </li>
  </ul>
</nav>

Upvotes: 2

Related Questions