Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts

    horizontal center div iside div

    style="float:left; must be there, how to horizontal center 'b' ?
    This does not work, any ideas ?

    Code:
    <DIV style = "text-align:center;" >
        <DIV>
            <a style="float:left;">b</a>
        </DIV>
    </DIV>

  • #2
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    this works as long there is only one char of text, more characters does not work anymore
    any other idea ?

    Code:
     <DIV style = " margin-left: 50&#37;;margin-right: 50%;">
       <a style="float:left;">b</a>
     </DIV>

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Your intention is not clear... please explain.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #4
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    style="float:left; must be there, because I have a bunch of things there instead of 'b'
    but they doesn't get centered because of a tag float:left.

    to get clear: want to center this code inside any div:

    Code:
    <a style="float:left;">b</a>
    so far I got this, it works(FF, IE7), but I dont like this absolute 30 px stuff becuse:
    1. b has variable length (px)
    2. b can appear in variable length DIV tags.

    Can this be done any other way ?

    Code:
     <DIV style = " margin-left: 30px;">
       <DIV>
         <a style="float:left;">b</a>
       </DIV> 
    </DIV>
    Last edited by BubikolRamios; 01-20-2008 at 08:02 AM.

  • #5
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    style="float:left; must be there, because I have a bunch of things there instead of 'b'
    This is not clear. Why do you need to use float for the above purpose. Even if you have many <a> elements to be displayed side by side, no need to use float, since <a> is an inline tag.

    I think display:block is what you are looking for.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •