Web Analytics Made Easy -
StatCounter Text in div won't center-align - CodingForum

Announcement

Collapse
No announcement yet.

Text in div won't center-align

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Text in div won't center-align

    Hello,

    This is a small, irritating problem.
    On a single page I've got 3 divs, all of which are supposed to be aligned to center. While the first two are working perfectly, the third won't align to center no matter what I do.
    As far as I can tell, the code's fine. Am I missing something?
    (The text may seem to be too short to align to anything, but the original is in a different language so it actually spans several rows of text.)

    Code:
    #office
    {
    position:absolute;
    text-align:center;
    width: 100px;
    height: 40px;
    top:60px;
    left:50px;
    }
    
    #accounting
    {
    position:absolute;
    top:60px;
    left:200px;
    text-align: center;
    width: 150px;
    height: 40px;
    }
    
    #projects
    {
    text-align: center;
    position:absolute;
    width: 40px;
    height: 40px;
    top: 200px;
    left: 200px;
    }
    
    ...
    
    
    <div id="office">Office services</div>
    <div id="accounting">Accounting services</div>
    <div id="projects">Project management</div>
    Thanks!

  • #2
    Share full code (HTML and CSS ) .. If possible share working link,,,...

    Comment


    • #3
      Originally posted by pandoradora View Post
      On a single page I've got 3 divs, all of which are supposed to be aligned to center.
      align centre vertically or horizontally?

      The first 2 are lining up horizontally and the 3rd div is below them.

      Comment


      • #4
        Hi, do you mean the text?

        I think it is centre aligning properly but you have set the width for that textbox to only 40px. I dont think this is enough space for the text itself to fit.

        Try increasing the width of the Projects div.

        Comment


        • #5
          Yes, I did mean the text inside the divs. And changing the width did the trick.
          Thanks, Chaule, and everyone else who replied.

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎