Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Control not getting centered

Control not getting centered

Scheduled Pinned Locked Moved Web Development
csharphtmlasp-netdesignhelp
11 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gjm
    wrote on last edited by
    #1

    I am new to Web Design. I have a set of div tags as shown below. My problem is the asp.net login control is not displayed at the center of the division. What should I do inorder to make it centered. The ASp.net design view displays the login control centered in the div but when I run the page in a browser it aligns to left. What to do? Here is the markup

    I am the header

    D P 2 Replies Last reply
    0
    • G Gjm

      I am new to Web Design. I have a set of div tags as shown below. My problem is the asp.net login control is not displayed at the center of the division. What should I do inorder to make it centered. The ASp.net design view displays the login control centered in the div but when I run the page in a browser it aligns to left. What to do? Here is the markup

      I am the header

      D Offline
      D Offline
      dkedar2010
      wrote on last edited by
      #2

      for center DIV You must use Abosolute position instead of relative position in your case .Panel1 { position:absolute; width:125px; height:50px; left:50%; top:50%; margin-left:-62.5px; margin-top:25px; } and use this class

      L 1 Reply Last reply
      0
      • D dkedar2010

        for center DIV You must use Abosolute position instead of relative position in your case .Panel1 { position:absolute; width:125px; height:50px; left:50%; top:50%; margin-left:-62.5px; margin-top:25px; } and use this class

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Be cautious when using absolute positioning. It is outside the normal flow of the document.

        D 1 Reply Last reply
        0
        • L Lost User

          Be cautious when using absolute positioning. It is outside the normal flow of the document.

          D Offline
          D Offline
          dkedar2010
          wrote on last edited by
          #4

          Can you please explain your point?

          L 1 Reply Last reply
          0
          • D dkedar2010

            Can you please explain your point?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            I did not say "don't use", but be cautious when using absolute positioning. Note : I did not criticize the css code you posted. You can read here of the different types of positioning http://reference.sitepoint.com/css/positioning[^] [added]I understand there is a video available here that uses MS Expressions Web to explain positioning http://www.learnexpression.com/Videos/EW-08/Positioning/Positioning.html[^][/added]

            modified on Tuesday, August 3, 2010 6:28 AM

            J D 2 Replies Last reply
            0
            • L Lost User

              I did not say "don't use", but be cautious when using absolute positioning. Note : I did not criticize the css code you posted. You can read here of the different types of positioning http://reference.sitepoint.com/css/positioning[^] [added]I understand there is a video available here that uses MS Expressions Web to explain positioning http://www.learnexpression.com/Videos/EW-08/Positioning/Positioning.html[^][/added]

              modified on Tuesday, August 3, 2010 6:28 AM

              D Offline
              D Offline
              dkedar2010
              wrote on last edited by
              #6

              I am not using absolute position frequently, but in Gjm's case I used this position for center div in the page, If you know other that this solution then please post it

              L 1 Reply Last reply
              0
              • L Lost User

                I did not say "don't use", but be cautious when using absolute positioning. Note : I did not criticize the css code you posted. You can read here of the different types of positioning http://reference.sitepoint.com/css/positioning[^] [added]I understand there is a video available here that uses MS Expressions Web to explain positioning http://www.learnexpression.com/Videos/EW-08/Positioning/Positioning.html[^][/added]

                modified on Tuesday, August 3, 2010 6:28 AM

                J Offline
                J Offline
                januka111
                wrote on last edited by
                #7

                ;P :zzz:

                1 Reply Last reply
                0
                • D dkedar2010

                  I am not using absolute position frequently, but in Gjm's case I used this position for center div in the page, If you know other that this solution then please post it

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  If the code you and Gjm then uses works, then that is all that matters. Other ways to centre a div include margin-right : auto and margin-left : auto when using the CSS box model. As I said above, I'm not criticizing the code you used. Shall we leave it at that ???

                  D 1 Reply Last reply
                  0
                  • L Lost User

                    If the code you and Gjm then uses works, then that is all that matters. Other ways to centre a div include margin-right : auto and margin-left : auto when using the CSS box model. As I said above, I'm not criticizing the code you used. Shall we leave it at that ???

                    D Offline
                    D Offline
                    dkedar2010
                    wrote on last edited by
                    #9

                    My friend, margin-right : auto and margin-left : auto is working but only on on horizontal center not vertical center on the page , if you want both side center (center on the page on any resolution) then this css rule is useless, You can try it and get result

                    1 Reply Last reply
                    0
                    • G Gjm

                      I am new to Web Design. I have a set of div tags as shown below. My problem is the asp.net login control is not displayed at the center of the division. What should I do inorder to make it centered. The ASp.net design view displays the login control centered in the div but when I run the page in a browser it aligns to left. What to do? Here is the markup

                      I am the header

                      P Offline
                      P Offline
                      Prosanta Kundu online
                      wrote on last edited by
                      #10

                      Try this

                      <div id="hd" style="display:table;vertical-align:middle;position: relative; text-align: center; background-color: gray; width: 100%; height: 500px; top: 0px; left: 0px;">
                      <div id="c" style="display:table-cell;vertical-align:middle;text-align:center;position:relative;top:225px;">
                      <div style="width:125px;height:50px;">
                      <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px">
                      <asp:Login ID="Login1" runat="server" Style="position: relative">
                      </asp:Login>
                      </asp:Panel> I am the header
                      </div>

                      </div>
                      

                      </div>

                      D 1 Reply Last reply
                      0
                      • P Prosanta Kundu online

                        Try this

                        <div id="hd" style="display:table;vertical-align:middle;position: relative; text-align: center; background-color: gray; width: 100%; height: 500px; top: 0px; left: 0px;">
                        <div id="c" style="display:table-cell;vertical-align:middle;text-align:center;position:relative;top:225px;">
                        <div style="width:125px;height:50px;">
                        <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px">
                        <asp:Login ID="Login1" runat="server" Style="position: relative">
                        </asp:Login>
                        </asp:Panel> I am the header
                        </div>

                        </div>
                        

                        </div>

                        D Offline
                        D Offline
                        dawmail333
                        wrote on last edited by
                        #11

                        My friend, you made the fatal mistake of thinking all browsers are fairly standards-compliant. :(

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups