Jimmy
Jimmy

Reputation: 12487

Getting image and list to appear on the same line

This is my code: http://jsfiddle.net/FMfDM/1/

I can't seem to get my logo image to sit on the same line as my list, even if I put display:inline on the image.

Can anyone please tell me what is the proper approach to this, since using float: right is also making my list items appear in reverse order!

Upvotes: 0

Views: 57

Answers (5)

Scott Meyers
Scott Meyers

Reputation: 161

Like Cliff mentioned, you'll need to float the left img or anchor.

http://jsfiddle.net/scottmey/BKWrR/

#nav a, #nav img {
    float:left;
}

and consider:

#nav ul {
    float: right;
}

Upvotes: 1

Maurice Botha
Maurice Botha

Reputation: 125

<nav id="nav">
  <a href="index.html"><img style="float:left" src="logo.png" id="logo"></a>
  <ul>
     <li><a href="features.html">Features</a></li>
     <li><a href="pricing.html">Pricing</a></li>
     <li><a href="signup.html">Sign up</a></li>
     <li><a href="login.html">Login</a></li>
  </ul>
</nav>

Upvotes: 0

Mohammad Kermani
Mohammad Kermani

Reputation: 5396

jsfiddle

html

    <nav id="nav">

  <ul>
      <a href="index.html"><img src="logo.png" id="logo"/></a>
     <li><a href="features.html">Features</a></li>
     <li><a href="pricing.html">Pricing</a></li>
     <li><a href="signup.html">Sign up</a></li>
     <li><a href="login.html">Login</a></li>
  </ul>
</nav>

and css

* {
    padding:0px;
    margin:0px;
}


ul li{
  display: inline;
    float: right;
}
li {
    list-style-type: none;
    background:gold;
    width:80px;
    border:1px solid black;
    text-align:center;
}

#nav {padding-top: 30px;}

you can change color and everything else what you like!

Upvotes: 1

Alex Angelico
Alex Angelico

Reputation: 4035

try <ul style="display:inline;">

Upvotes: 1

Cliff Ribaudo
Cliff Ribaudo

Reputation: 9039

That will do it:

#nav img {float:left;}

Upvotes: 1

Related Questions