DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Sat, 11 Aug 2007 19:48:54 +0530,    posted on: microsoft.public.dotnet.framework        back       

Thread Index
  1    Barry
          2    Scott M. am
          3    Göran Andersson
                 4    Barry
                 5    Göran Andersson


CSS Related question   
Hi

How do i center-align a items within a <div></div> tag

TIA
Barry
Date:Sat, 11 Aug 2007 19:48:54 +0530   Author:  

Re: CSS Related question   
<div style="text-align:center">



"Barry"  wrote in message 
news:%23aa0MKC3HHA.5796@TK2MSFTNGP05.phx.gbl...

> Hi
>
> How do i center-align a items within a <div></div> tag
>
> TIA
> Barry
> 
Date:Sat, 11 Aug 2007 10:28:52 -0400   Author:  

Re: CSS Related question   
Barry wrote:

> How do i center-align a items within a <div></div> tag


If the item is a block element, on the item use:

margin-left: auto;
margin-right: auto;

If the item is an inline element, on the div tag use:

text-align: center;

-- 
Gran Andersson
_____
http://www.guffa.com
Date:Sun, 12 Aug 2007 04:26:58 +0200   Author:  

Re: CSS Related question   
if i use

<div style="margin-left: auto;margin-right: auto;text-align: center;"> 
gridview is here</div>

the grid view within the div is centered alright, but all the Text in the 
columns is also centered, which i need left-aligned (by default)



"Gran Andersson"  wrote in message 
news:eSeBIhI3HHA.3900@TK2MSFTNGP02.phx.gbl...

> Barry wrote:
>> How do i center-align a items within a <div></div> tag
>
> If the item is a block element, on the item use:
>
> margin-left: auto;
> margin-right: auto;
>
> If the item is an inline element, on the div tag use:
>
> text-align: center;
>
> -- 
> Gran Andersson
> _____
> http://www.guffa.com 
Date:Sun, 12 Aug 2007 14:23:59 +0530   Author:  

Re: CSS Related question   
Barry wrote:

> if i use
> 
> <div style="margin-left: auto;margin-right: auto;text-align: center;"> 
> gridview is here</div>
> 
> the grid view within the div is centered alright,


That is only because you are looking at it in Internet Explorer, which 
applies text-align to block elements although it shouldn't. If you look 
at it in a more standards compliant browser, the grid isn't centered.

You applied the margin to the div, not to the item as I said. However, 
as the div doesn't have a specific size, the margin will still be zero. 
If you want to center a block, it has to have a specific width.


> but all the Text in the 
> columns is also centered, which i need left-aligned (by default)


That's because you tried to use both methods. An element can't be both a 
block element and an inline element.


> 
> "Gran Andersson"  wrote in message 
> news:eSeBIhI3HHA.3900@TK2MSFTNGP02.phx.gbl...
>> Barry wrote:
>>> How do i center-align a items within a <div></div> tag
>> If the item is a block element, on the item use:
>>
>> margin-left: auto;
>> margin-right: auto;
>>
>> If the item is an inline element, on the div tag use:
>>
>> text-align: center;
>>
>> -- 
>> Gran Andersson
>> _____
>> http://www.guffa.com 
> 
> 



-- 
Gran Andersson
_____
http://www.guffa.com
Date:Sun, 12 Aug 2007 14:51:23 +0200   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us