简体   繁体   中英

Why won't my text float to the right?

Basically I wanted the Sign in link to be on the right and my logo to be where it is. I'm still a newbie at CSS and I've tried all that I could think of in terms of the code. Here's the HTML:

<!--header-->
    <div id="header">
        <a href="#" id="logo">IMG</a>
        <a href="" id="signIn">Sign into CGC!</a>   
    </div>

And here is the CSS:

#div header{
font-family; sans-serif;

}
#div a signIn{
    float: right;
}

Any advice would be appreciated.

Your selectors are incorrect:

div#header{
  font-family; sans-serif;
}

div#header a#signIn{
  float: right;
}

Since you've assigned an ID you can just use:

 #signIn{
    float: right;
 }

Your code specifies a 'signIn' element, that is a child of an anchor element, that is a child of an element with the ID 'div'. Hope that's clear.

Same goes for the header

 #header{ 
   font-family; sans-serif;
 }

Use this code:

Fiddle:

CSS:

div#header{
font-family; sans-serif;

}
div a#signIn{
    float: right;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM