Reputation: 317
Currently, my page's content header looks like this:
But I would like the contents to look something like this:
Here's the HTML involving that portion of the page:
<div class="header">My Tools<a href="#possess" class="anchor_link">View Tools you Possess</a></div>
And my CSS for the involved classes:
#content .header{
font-size:180%;
width:1000px;
border-bottom:1px solid #000000;
}
#content .header .anchor_link{
font-size:100%;
text-align:right;
text-decoration:none;
color:#0059FF;
}
Can you explain what I'm doing wrong here, so that I can get by desired appearance?
For future reference: I solved the font-size problem, because the 100% is in reference to the parent div, so to make this text smaller, I changed the anchor's font-size to 60%
Upvotes: 1
Views: 100
Reputation: 5610
About font-size
you can't override parent properties so wrap MyTools in <span>
like below, here's a FIDDLE
<div class="header"><span>My Tools</span><a href="#possess" class="anchor_link">View Tools you Possess</a></div>
.header {
width:600px;
border-bottom:1px solid #000000;
}
.header .anchor_link {
font-size:100%;
float:right;
margin-top:14px;
text-decoration:none;
color:#0059FF;
}
.header span {
font-size:180%;
}
Upvotes: 1
Reputation: 1987
As everybody has mentioned, you have to use float:right;
on the anchor link, the reason that text-align: right;
didn't worked is <a>
is a an inline element, hence its white space area doesn't stretches like a block level element for e.g. <p>, <div>
.
Upvotes: 2
Reputation: 15699
Change
#content .header .anchor_link{
text-align:right;
}
to
#content .header .anchor_link{
float:right;
}
Upvotes: 5
Reputation: 35963
Use float:right
try this:
#content .header .anchor_link{
font-size:100%;
float:right;
text-decoration:none;
color:#0059FF;
}
Upvotes: 1