Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2007

Tip: Looking for answers? Try searching our database.

CSS Related question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Barry - 11 Aug 2007 15:18 GMT
Hi

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

TIA
Barry
Scott M. - 11 Aug 2007 15:28 GMT
<div style="text-align:center">

> Hi
>
> How do i center-align a items within a <div></div> tag
>
> TIA
> Barry
Göran Andersson - 12 Aug 2007 03:26 GMT
> 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;

Signature

Göran Andersson
_____
http://www.guffa.com

Barry - 12 Aug 2007 09:53 GMT
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)

>> How do i center-align a items within a <div></div> tag
>
[quoted text clipped - 6 lines]
>
> text-align: center;
Göran Andersson - 12 Aug 2007 13:51 GMT
> 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.

>>> How do i center-align a items within a <div></div> tag
>> If the item is a block element, on the item use:
[quoted text clipped - 5 lines]
>>
>> text-align: center;

Signature

Göran Andersson
_____
http://www.guffa.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.