Jump to:

23023 Posts in 11882 Topics by 2830 members

General Questions

SilverStripe Forums » General Questions » Problems with centering an invisible table

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1442 Views
  • Marco_D
    Avatar
    Community Member
    20 Posts

    Problems with centering an invisible table Link to this post

    Hey guys,

    currently I am trying to center an invisible table. The table alignment is set to "center", but in this case the table is still shown on the left.
    This is my source code:

    <table border="0" align="center">
    <tbody>
    <tr>
    <td style="text-align: center;">
    <div class="image center" style="width: 360px; text-align: center;"><img src="assets/Uploads/schlaf1.jpg?r=95536" alt="" width="360" height="270" /></div>
    Im Schlafzimmer befindet sich ein Doppelbett<br /> (Bei Bedarf ist eine Aufbettung oder Baby-Bett vorhanden)</td>
    </tr>
    </tbody>
    </table>


    Is there any solution?

    Thanks in advance
    Greetings from Karlsruhe, Germany
    Marco

  • Marco_D
    Avatar
    Community Member
    20 Posts

    Re: Problems with centering an invisible table Link to this post

    Can anyone provide some help?

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Problems with centering an invisible table Link to this post

    Your align "instructions" effect the contents of the table, not the table itself.
    To center your table I'd try something along these lines:

    <div style="text-align:center;">
       <table>
          ... table content ...
       </table>
    </div>

    I hope your code doesn't look exactly like the one you posted though. Because in that case you won't need a table at all

  • Marco_D
    Avatar
    Community Member
    20 Posts

    Re: Problems with centering an invisible table Link to this post

    Hey guys,

    @banal: thanks for your advice.

    I tried different options, the solution I have found is the following:

    <div style="text-align: center">
    <div class="image center" style="margin: 0px auto; width: 360px; text-align: center;"><img src="assets/Uploads/_resampled/ResizedImage360270-schlaf1.jpg" alt="" width="360" height="270" /></div>
    Im Schlafzimmer befindet sich ein Doppelbett<br /> (Bei Bedarf ist eine Aufbettung oder Baby-Bett vorhanden)</div>


    The crux is

    margin: 0px auto;


    which aligns the image at the center.

    Kind Regards
    Marco

    1442 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.