Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Centering a DIV and engages the text

.net programming

  • Please log in to reply
2 replies to this topic

#1 pauljameson141

pauljameson141

    CC Lurker

  • New Member
  • Pip
  • 4 posts
  • Programming Language:C, Java, C++, PHP, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, VBScript
  • Learning:Perl, Ruby, Lisp, Pascal

Posted 30 August 2012 - 02:25 AM

Hello,

my intention is to make a DIV the same as I do with this table:

Code:
<Table style = "background-color: # AFEEEE;
margin: 0 auto 0 auto;
border-width: medium; border-style: outset; ">
<tr>
<td align="center"">
Form 1
</ Td>
</ Tr>
</ Table>



So I need a box, centered, and that also suits the content, I do not want to put width, I want to automatically take the size of the text you have inside. I managed latter putting display: inline, but if I put that I cannot focus box.

Any idea?
  • 0

#2 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 30 August 2012 - 03:19 AM

You can try:
<div style="text-align: center;" >
  <div style="display:inline-block; text-align: left;">
	  <!-- hopefully centered -->
  </div>
</div>

  • 0

#3 VNFox

VNFox

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 648 posts
  • Programming Language:C#, PHP
  • Learning:Assembly

Posted 30 August 2012 - 08:40 AM

For me I think using table is absolutely ok ... don't listen to people that have to always convert "table" to "div". With the fast browser now aday ... u won't notice any different between the table vs div. I 've found that using table works perfectly across the browser vs div. (well at least it's my opinion :) )
  • 0

www.pickmike.com
I don't just develop software. I find solutions to your business needs.






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download