/    Sign up×
Community /Pin to ProfileBookmark

Alternative for middle aligning

Hello. I have a list of links on a webpage that I have aligned in the middle of the link area by using the line-height property setting that to the height of the link box. However, if a link is too long to fit on one line and needs to drop to a second line, it falls apart and makes the link box way too big because the second line has the large line height. Any alternative for aligning something vertically in a box other than line height? Thanks.

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@jasonahouleMar 09.2007 — Are you using a list? Post a sample of the code.
Copy linkTweet thisAlerts:
@KDLAMar 09.2007 — Select a padding setting which "fakes" your text being in the middle of the block:
<i>
</i>&lt;ul&gt;
&lt;li style=" display: block; width: 12em; [B]font-size: .8em; padding: .4em .1em;[/B] border: 1px solid #000;"&gt;Normal Link box&lt;/li&gt;
&lt;li style=" display: block; width: 12em; [B]font-size: .8em; padding: .4em .1em;[/B] border: 1px solid #000;"&gt;Really, Really Really Long Name Link box&lt;/li&gt;
&lt;/ul&gt;
Copy linkTweet thisAlerts:
@bp_travisauthorMar 09.2007 — Sample Code:

CSS
[CODE]
ul{
list-style:none;
margin: 0;
padding: 0;
}

#menu {
width: 200px;
height:auto;
margin: 0px;
float: left;
}

#menu li a {
height: 35px;
voice-family: ""}"";
voice-family: inherit;
height: 27px;
text-decoration: none;
font-weight: bold;
font-family:Comic Sans MS;
}

#menu li a:link, #menu li a:visited {
color:#DFD61A;
line-height:35px;
margin-left:auto;
margin-right:auto;
display: block;
background: url(images/s_link_off_green.jpg);
height:40px;
font-size: 12px;
}

#menu li a:hover{
background:url(images/s_link_on_blue.jpg);
}[/CODE]


HTML
[code=html]
<ul>
<li><a href="#">Staff</a></li>
<li><a href="#">About Off-Lead</a></li>
<li><a href="https://www.barkleigh.com/OL_subscribe.html">Subscribe</a></li>
<li><a href="mailto:[email protected]">Contact US </a></li>
<li><a href="#">Products,Books,DVD's</a></li>
<li><a href="#">Articles</a></li>
<li><a href="https://www.barkleigh.com/mailing.html" target="_blank">Join the Mailing List</a></li>
<li><a href="#">Trainer's Round Table</a></li>
<li><a href="#">Advertising</a></li>
<li><a href="#">Learning Opportunities & Seminars</a></li>
</ul>
[/code]

Thanks
×

Success!

Help @bp_travis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...