Solved

CSS Text height and Div height

Posted on 2011-02-26
4
741 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

688 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