Solved

CSS Text height and Div height

Posted on 2011-02-26
4
730 Views
Last Modified: 2012-08-13
I have a Div with

      height: 120px;
      margin: auto;

I have a another Div with
      font-size:20px;
      line-height:1;
      padding-top : 25px;

I then have HTML
<div id="Header">
     <div class="headerText">
           <span id="ctl00_lblTitle" class="headerText">My Text</span>
      </div>
 </div>

I would expect "My Text" to appear in the center of the first Div  as (120-20)/2=25 but it does not.

How do I fix this?
0
Comment
Question by:PhotoCompManager
  • 2
4 Comments
 
LVL 16

Expert Comment

by:sjklein42
ID: 34986837
(120-20)/2=25

I don't think so.  I think it equals 50

0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 34988090
try

<div id="Header">
     <div class="headerText">
           <span id="ctl00_lblTitle" class="headerText">My Text</span>
      </div>
 </div>

.headerText
{
   width:120px;
}
.headerText span
{
   width:20px;
   margin-left:50px;
}
0
 

Author Comment

by:PhotoCompManager
ID: 34990893
Gurvinder 372 - I need to align vertically not horizontally

Sjklein42 - true - the problems of making a simplified version for the question!

However the issue is still the same with  
      font-size:20px;
      line-height:1;
      padding-top : 50px;

0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 34990966
then do the same thing with top and bottom margin

<div id="Header">
     <div class="headerText">
           <span id="ctl00_lblTitle">My Text</span>
      </div>
 </div>

.headerText
{
   height:120px;
}
.headerText span
{
   height:20px;
   margin-top:50px;
}

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now