cattleyana
cattleyana

Reputation: 11

make logo and list menu on the same navbar

i want to make my logo and navigation list on the same nav-bar. At first, before i put the logo the nav-list worked well inline-but after i put the logo it started to make a new line (the nav-list).

i would be so glad if you all can help me. You can help to check my code on codepen here

or i will post it here. Thank You. I really appreciate your help.

body{
  margin: 0;
  font-family: arial;
}

#background-img{
  width: 100%;
  border: 1px solid black;
  height: 198px;
  background: url('http://auxanograhicdesigns.com/media/wysiwyg/auxano/digital-marketing-services/web-designing-services/photoshop-banner-template-beautifull-web-banner-designs.jpg')
}

#nav-bar{
  top: 0;
  position:absolute;
  width: 100%;
  height: 63px;
  background-color: rgba(42, 34, 41, 0.6);
}
.logo{
  width: 86px;
  height:63px;;
  background-color: purple;
  margin-left: 30px;
  float:left;
  display: inline-block;
  color: white;
}

.logo p{
  text-align:center;
  padding-bottom: px;
  font-size: 30px;
}
#nav-bar ul{
  list-style-type: none;
  float: right;
}

#nav-bar li{
  display: inline-block;
  padding: 1%;
}

#nav-bar a {
  text-decoration: none;
  color: white;
  
}
<body>
  <div id = "wrapper">
    <div id = "background-img">
      <div id = "nav-bar">
        <a class = "logo" href = "#"><p>Ps</p></a>
       <nav>       
        <ul>
          <li><a href = "#">Home</a></li>
          <li><a href = "#">About</a></li>
          <li><a href = "#">Portofolio</a></li>
          <li><a href = "#">Contact</a></li>
        </ul>
      </nav>
      </div>
    </div>
  </div>
</body>

Upvotes: 0

Views: 72

Answers (1)

capcj
capcj

Reputation: 1535

Ajust the width of nav ul as you wish. Your error was working with float (is very annoying and difficult to rely on that) and to add a div as nav container: poorly to SEO and just useless content, with more code into HTML. Check CodePen

<body>
  <div id = "wrapper">
    <div id = "background-img">
       <nav>
         <a class = "logo" href = "#"><p>Ps</p></a>
        <ul>
          <li><a href = "#">Home</a></li>
          <li><a href = "#">About</a></li>
          <li><a href = "#">Portofolio</a></li>
          <li><a href = "#">Contact</a></li>
        </ul>
      </nav>
    </div>
  </div>
</body>
 <!-- https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAANSAAAAJGRhYzRlMjllLTNlZTMtNDA1OS1iN2M2LTQ5NDI4YmFjZjJhOA.png --!>

body{
  margin: 0;
  font-family: arial;
}

#background-img{
  width: 100%;
  border: 1px solid black;
  height: 198px;
  background: url('http://auxanograhicdesigns.com/media/wysiwyg/auxano/digital-marketing-services/web-designing-services/photoshop-banner-template-beautifull-web-banner-designs.jpg')
}

nav{
  top: 0;
  position:absolute;
  width: 100%;
  height: 63px;
  background-color: rgba(42, 34, 41, 0.6);
}
.logo{
  width: 86px;
  height:63px;;
  background-color: purple;
  margin-left: 30px;
  display: inline-block;
  color: white;
}

.logo p{
  text-align:center;
  padding-bottom: px;
  font-size: 30px;
}
nav ul{
  text-align: right;
  list-style-type: none;
  display: inline-block;
  width: 90%;
}

nav li{
  display: inline;
  padding: 1%;
}

nav a {
  text-decoration: none;
  color: white;

}

Upvotes: 1

Related Questions