Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / CSS / November 2007



Tip: Looking for answers? Try searching our database.

Help Vertially Centering a Span within a Div

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
~john - 29 Nov 2007 15:03 GMT
I'm building an hmtl form and trying deperately not to go back to
table positioning... I have a series of checkboxes on the right and
the label on the left. I want the label on the left to be vertically
centered with the checkboxes on the right. I can't seem to find a way
to do this. I dont want to use pixel positioning because the number of
checkboxes on the right will change dynamically. Any ideas? My code is
posted below... If there's an easier to way to accomplish the look I'm
after please let me know.. thanks!

<style type="text/css">
.NSDFormDiv
{
   border-style: solid;
   border-color: #D8D8D8;
   border-width: 1px 0 0 0;
   width: 600;
   background-color: blue;
}
.NSDFormLbl
{
    width: 200;
    font-family: Verdana;
    font-size: 11;
    font-weight: bold;
    color: #525252;
    background-color: red;
}
.NSDFormBackground
{
    background-color: #EBF3FF;
    width: 400;
    padding: 3 5 3 5;
}
</style>

<div class="NSDFormDiv">

    <span class="NSDFormLbl">Center Me Vertically</span><span
class="NSDFormBackground">

    <input type="checkbox" /><label>Business Objects (Reporting
application)</label>
    <div></div>
    <input type="checkbox" /><label>MIPS (Mill Production System)</label>
    <div></div>
    <input type="checkbox" /><label>Great Plains (Accounting & HR
application)</label>
    <div></div>
    <input type="checkbox" /><label>Microsoft Project</label>
    <div></div>
    <input type="checkbox" /><label>IFS (Purchasing system)</label>
    <div></div>
    <input type="checkbox" /><label>VPN</label>

    </span>
</div>
Johannes Koch - 29 Nov 2007 17:47 GMT
~john schrieb:
[...]
> My code is posted below...

1. Validate the markup (There are errors in your code).
2. Validate the CSS (There are errors in your code).
3. Don't post code, post a URL to a minimal demo instead.

Signature

Johannes Koch
Spem in alium nunquam habui praeter in te, Deus Israel.
                         (Thomas Tallis, 40-part motet)

tor.brekke.skjotskift@gmail.com - 30 Nov 2007 14:36 GMT
> I'm building an hmtl form and trying deperately not to go back to
> table positioning... I have a series of checkboxes on the right and
[quoted text clipped - 52 lines]
>         </span>
> </div>

You can center inline elements vertically with vertical-align:middle
and line-height set to 100% of the containing element.

Tor
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.