Baljit Singh
Baljit Singh

Reputation: 13

How can I move my logo to the top left side in the header?

How can I shift my logo to top left side in the header bar? I tried most of the time but code is not executed. My HTML code and CSS code is below:

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&family=Ubuntu:wght@400;500;700&display=swap');

/* Selector ke bare me aache se padh lo
    */

* {
  margin: 0px;
  padding: 0px;
  box-sizing: border-box;
  text-decoration: none;
}

.max-width {
  max-width: 1300px;
  padding: 0 80px;
  margin: auto;
}


/* navbar styling */

.navbar {
  position: fixed;
  width: 100%;
  padding: 30px, 0;
  background-color: none;
  font-family: 'Ubuntu', 'sans-serif';
}

.navbar.sticky {
  padding: 30px, 0;
  background: crimson;
}

.navbar .max-width {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar .logo a {
  align-items: left;
  color: #fff;
  font-size: 35px;
  font-weight: 600;
}

.navbar .logo {
  /* text-align:left;    // want this logo to the top left side but this is not happning */
  padding-top: 30px;
}

.navbar .logo a span {
  color: crimson;
}

.navbar .menu li {
  padding-top: 18px;
  list-style: none;
  display: inline-block;
}

.navbar .menu li a {
  color: #fff;
  font-size: 18px;
  font-weight: 500px;
  margin-left: 25px;
  transition: color 0.3s ease;
}

.navbar .menu li a:hover {
  color: crimson;
}


/* home section styleing */

.home {
  display: flex;
  background-size: cover;
  background-attachment: fixed;
  background-image: url(/banner.jpg);
  background-repeat: no-repeat;
  background-position: center;
  height: 100vh;
  color: #fff;
  min-height: 500px;
  font-family: 'Ubuntu', 'sans-serif';
}

.home .max-width {
  margin: auto 0. auto 40px;
  margin-left: -3px;
}

.text-1 {
  font-size: 27px;
}

.text-2 {
  font-size: 75px;
  font-weight: 600;
}

.text-3 {
  font-size: 40px;
  margin: 5px 0;
}

.home .text-3 span {
  color: crimson;
  font-weight: 500;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Portfolio Website</title>
  <link rel="stylesheet" href="website.css">
  <script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
  <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
</head>

<body>


  <nav class="navbar">
    <div class="max-width">
      <div class="logo"> <a href="#">Portfo<span>lio.</span></a></div>

      <ul class="menu">
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Services</a></li>
        <li><a href="#">Skills</a></li>
        <li><a href="#">Teams</a></li>
        <li><a href="#">Contact me</a></li>
      </ul>
    </div>

  </nav>

  <!-- home section start -->

  <section class="home">
    <div class="max-width">
      <div class="home-content"></div>
      <div class="text-1">Hello ji, My name is</div>
      <div class="text-2">Baljit Singh</div>
      <div class="text-3">And I'm a <span>Engineer</span> </div>
    </div>
  </section>

  <p style="text-align: center; padding: 8px ; font-size: larger;  ">This website is in under construction</p>




  <!-- <script src="website.js"></script> -->
</body>

</html>

Upvotes: 0

Views: 621

Answers (1)

Mahmudul Hasan
Mahmudul Hasan

Reputation: 122

Your logo is already on the left side. Probably you are not seeing it properly because of your background color. I have changed your background to black. Now you see.

* {
  margin: 0px;
  padding: 0px;
  box-sizing: border-box;
  text-decoration: none;
  background : black;
}

.max-width {
  max-width: 1300px;
  padding: 0 80px;
  margin: auto;
}


/* navbar styling */

.navbar {
  position: fixed;
  width: 100%;
  padding: 30px, 0;
  background-color: black;
  font-family: 'Ubuntu', 'sans-serif';
}

.navbar.sticky {
  padding: 30px, 0;
  background: crimson;
}

.navbar .max-width {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar .logo a {
  align-items: left;
  color: #fff;
  font-size: 35px;
  font-weight: 600;
}

.navbar .logo {
  /* text-align:left;    // want this logo to the top left side but this is not happning */
  padding-top: 30px;
}

.navbar .logo a span {
  color: crimson;
}

.navbar .menu li {
  padding-top: 18px;
  list-style: none;
  display: inline-block;
}

.navbar .menu li a {
  color: #fff;
  font-size: 18px;
  font-weight: 500px;
  margin-left: 25px;
  transition: color 0.3s ease;
}

.navbar .menu li a:hover {
  color: crimson;
}


/* home section styleing */

.home {
  display: flex;
  background-size: cover;
  background-attachment: fixed;
  background-image: url(/banner.jpg);
  background-repeat: no-repeat;
  background-position: center;
  height: 100vh;
  color: #fff;
  min-height: 500px;
  font-family: 'Ubuntu', 'sans-serif';
}

.home .max-width {
  margin: auto 0. auto 40px;
  margin-left: -3px;
}

.text-1 {
  font-size: 27px;
}

.text-2 {
  font-size: 75px;
  font-weight: 600;
}

.text-3 {
  font-size: 40px;
  margin: 5px 0;
}

.home .text-3 span {
  color: crimson;
  font-weight: 500;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Portfolio Website</title>
  <link rel="stylesheet" href="website.css">
  <script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
  <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
</head>

<body>


  <nav class="navbar">
    <div class="max-width">
      <div class="logo"> 
        <a href="#">Portfo<span>lio.</span> </a>
          
        </div>

      <ul class="menu">
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Services</a></li>
        <li><a href="#">Skills</a></li>
        <li><a href="#">Teams</a></li>
        <li><a href="#">Contact me</a></li>
      </ul>
    </div>

  </nav>

  <!-- home section start -->

  <section class="home">
    <div class="max-width">
      <div class="home-content"></div>
      <div class="text-1">Hello ji, My name is</div>
      <div class="text-2">Baljit Singh</div>
      <div class="text-3">And I'm a <span>Engineer</span> </div>
    </div>
  </section>

  <p style="text-align: center; padding: 8px ; font-size: larger;  ">This website is in under construction</p>




</body>

</html>

Upvotes: 1

Related Questions