Adrian Muntean Adrian Muntean - 8 days ago 4
CSS Question

CSS inline navigation menu and website title

So it's the first time I use CSS (been looking through some documentation) and I have this problem.

I created a navigation menu, a horizontal one on the right side, and I want to have the website title on the left side, inline with it. I tried a few things, but it either gets it up and moves the menu lower, or places it under the menu.

Last thing I tried worked but it seems that I can't use the padding-top property anymore (however, I can use padding-left). I would be grateful if any of you could help me with this last thing. Thank you!

The CSS code: (it's messy, I know, as I said, my first one :) )

ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
position: relative;
padding-top: 10px;
padding-right: 50px;
}

li {
float: right;
font-family: 'Raleway';
font-size: 20px;
}

a {
display: block;
padding: 20px;
background-color: transparent;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

a:hover {
color: orangered;
}


/* Logo */

#logo {
float: left;
display: inline-block;
position: relative;
padding-left: 200px;
padding-top: -250px;
font-family: 'Raleway';
font-size: 30px;
}


/* Fonts */


@font-face {
font-family: Raleway;
src: url(/css/fonts/raleway.ttf);
}

Answer

First, you can't put a <p> inside a <ul>.

You can achieve what you want by putting the logo inside a <li> and use float:left;.

ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    position: relative;
    padding-top: 10px;
    padding-right: 50px;
}

li {
    float: right;
    font-family: 'Raleway';
    font-size: 20px;
}

a {
    display: block;
    padding: 20px;
    background-color: transparent;
    color: black;   
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

a:hover {
    color: orangered;
}


/* Logo */

#logo {
    float: left;
    font-size: 30px;
}


/* Fonts */ 


@font-face {
    font-family: Raleway;
    src: url(/css/fonts/raleway.ttf);
}
                <ul>
                    <li id="logo">Cluj</li>
                    
                    <li><a href="contact.html">CONTACT</a></li>
                    <li><a href="imagini.html">IMAGINI</a></li>
                    <li><a href="stiri.html">STIRI</a></li>
                    <li><a href="evenimente.html">EVENIMENTE</a></li>
                    <li><a href="index.html">ACASA</a></li>
                </ul>

Comments