Yabusa
Yabusa

Reputation: 579

Is it possible to space an image to the left and the rest of the list to the right of a navigation bar?

I'm trying to set the logo to the left and the rest of the list to the right.

I tried removing it from the and adding it on it's own. it ends up behind the text even with a z-index= 2. I tried a and floated it to the left i found in another thread. still didn't work

* {
	font-family: arial, sans-serif; 
	box-sizing: border-box;}

html, body {
	margin: 0;
	padding: 0;
}

a {
	text-decoration: none;
	color: black;
}

.nav {
	position: fixed; 
	top: 0; 
	left: 0;
	background-color: rgba(255,255,255,.8);
	border-radius: 0px;
	border: none;
	width: 100%;
	margin: 0;
	padding: 25px 0;
	flex-direction: row;
	display: flex;
	align-items: center;
	justify-content: flex-end;
}

.item {
	color: black;
	font-weight: bold;
	text-transform: uppercase;
	font-size: 15px;
	margin-left: 30px;
	margin-right: 30px;
}
<nav>
	<ul class="nav">
		<li class="item">
			<a href="index.html">
				<img src="../Images/Navigation/Intak Logo 25px High.png" alt="Home" align="left"/>
			</a>
		</li>
		
		<li class="item has-children" style="color:#4D4D4D;">Printing

		</li>
		<li class="item has-children"><a href="Graphic Design.html">Graphic Design</a>

		</li>
		<li class="item has-children">Chinese Calendars
			<ul class="submenu">
				<li><a href="Calendars/Cane Wallscroll Calendars.html">Cane Wallscroll Calendars</a></li>
				<li><a href="Calendars/Wall Calendars.html">Wall Calendars</a></li>
				<li><a href="Calendars/Mini Calendars.html">Mini Calendars</a></li>
				<li><a href="Calendars/Desk Calendars.html">Desk Calendars</a></li>
				<li><a href="Calendars/Special Desk Calendars.html">Special Desk Calendars</a></li>
				<li><a href="Calendars/Red Packet.html">Red Packet</a></li>
				<li><a href="Calendars/More.html">More Calendars</a></li>
			</ul>
		</li>
		<li class="item"><a href="FAQS.html">FAQS</a></li>
		<li class="item"><a href="Contact Us.html">Contact Us</a></li>
	</ul>
</nav>

Need to some how split the logo from the nav and have it floated or positioned to the left

Upvotes: 1

Views: 56

Answers (2)

lala
lala

Reputation: 169

You should group all the other elements in a container, in the code below I've used another un order list. This way you can position the logo on one side and the other navigation elements on the other.

* {
	font-family: arial, sans-serif; 
	box-sizing: border-box;}

html, body {
	margin: 0;
	padding: 0;
}

a {
	text-decoration: none;
	color: black;
}

.nav {
	position: fixed; 
	top: 0; 
	left: 0;
	background-color: rgba(255,255,255,.8);
	border-radius: 0px;
	border: none;
	width: 100%;
	margin: 0;
	padding: 25px 0;
	flex-direction: row;
	display: flex;
	justify-content: space-between;
}

.item {
	color: black;
	font-weight: bold;
	text-transform: uppercase;
	font-size: 15px;
	margin-left: 30px;
	margin-right: 30px;
}

.inner-nav {
  display: flex;
}
<nav>
	<ul class="nav">
            <li class="item">
        <a href="index.html">
          <img src="../Images/Navigation/Intak Logo 25px High.png" alt="Home" align="left"/>
        </a>
      </li>
		<li>          
      <ul class="inner-nav">
        <li class="item has-children" style="color:#4D4D4D;">Printing

        </li>
        <li class="item has-children"><a href="Graphic Design.html">Graphic Design</a>

        </li>
        <li class="item has-children">Chinese Calendars
          <ul class="submenu">
            <li><a href="Calendars/Cane Wallscroll Calendars.html">Cane Wallscroll Calendars</a></li>
            <li><a href="Calendars/Wall Calendars.html">Wall Calendars</a></li>
            <li><a href="Calendars/Mini Calendars.html">Mini Calendars</a></li>
            <li><a href="Calendars/Desk Calendars.html">Desk Calendars</a></li>
            <li><a href="Calendars/Special Desk Calendars.html">Special Desk Calendars</a></li>
            <li><a href="Calendars/Red Packet.html">Red Packet</a></li>
            <li><a href="Calendars/More.html">More Calendars</a></li>
          </ul>
        </li>
        <li class="item"><a href="FAQS.html">FAQS</a></li>
        <li class="item"><a href="Contact Us.html">Contact Us</a></li>
      </ul>
    </li>



	</ul>
</nav>

Upvotes: 1

Donkey Shame
Donkey Shame

Reputation: 764

It appears that you'll want to separate out your home link from your navigation ul. Then make the <nav> element (to which I've assigned the class .nav-wrapper) a flex parent with justify-content property set to space-between. This will push the two elements (your <a> and your <ul>) to the left and right of their parent, respectively.

Then you can flex the <ul> itself so that its children (the <li>'s) arrange themselves in a neat horizontal row.

See below. You'll need to style this to your liking, but hopefully this will put you on the right path.

* {
  font-family: arial, sans-serif;
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

a {
  text-decoration: none;
  color: black;
  display: block;
}

.nav-wrapper {
  width: 100%;
  position: fixed;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav {
  margin-left: auto;
  background-color: rgba(255, 255, 255, .8);
  border-radius: 0px;
  border: none;
  margin: 0;
  padding: 0;
  display: flex;
}

.item {
  color: black;
  font-weight: bold;
  text-transform: uppercase;
  font-size: 15px;
  margin-left: 30px;
  margin-right: 30px;
}
<nav class="nav-wrapper">
  <a href="index.html">
    <img src="http://placehold.it/64x64" alt="Home" align="left" />
  </a>
  <ul class="nav">

    <li class="item has-children" style="color:#4D4D4D;">Printing

    </li>
    <li class="item has-children"><a href="Graphic Design.html">Graphic Design</a>

    </li>
    <li class="item has-children">Chinese Calendars
      <ul class="submenu">
        <li><a href="Calendars/Cane Wallscroll Calendars.html">Cane Wallscroll Calendars</a></li>
        <li><a href="Calendars/Wall Calendars.html">Wall Calendars</a></li>
        <li><a href="Calendars/Mini Calendars.html">Mini Calendars</a></li>
        <li><a href="Calendars/Desk Calendars.html">Desk Calendars</a></li>
        <li><a href="Calendars/Special Desk Calendars.html">Special Desk Calendars</a></li>
        <li><a href="Calendars/Red Packet.html">Red Packet</a></li>
        <li><a href="Calendars/More.html">More Calendars</a></li>
      </ul>
    </li>
    <li class="item"><a href="FAQS.html">FAQS</a></li>
    <li class="item"><a href="Contact Us.html">Contact Us</a></li>
  </ul>
</nav>

Upvotes: 1

Related Questions