Wrox Programmer Forums
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 16th, 2011, 04:25 AM
Authorized User
 
Join Date: Apr 2005
Posts: 71
Thanks: 23
Thanked 0 Times in 0 Posts
Default Positioning of a Button

Hi, i am trying to center a button in a table but i can't find a solution. Any ideas,

Many Thanks
Mark
 
Old September 16th, 2011, 02:00 PM
Friend of Wrox
 
Join Date: Apr 2010
Posts: 125
Thanks: 20
Thanked 3 Times in 3 Posts
Default

Can you elaborate more in details? Question is more general.
However if the table have only one column , add style = 'text-align:center;' attribute to td that contain button.
If table have more column you should add colspan = 'number of table columns' attribute to td that contain button and again add style = 'text-align:center;' .
There is another way to centralized a button in the container element(td element): set width of button use css rule or style attribute . for example width:100px. Then add margin-right:auto;margin-left:auto css rules. It makes button floated in middle of page.
Do you understand CSS language?
Could i help You??
__________________
Please excuse me for poor and bad English.
 
Old September 18th, 2011, 01:28 PM
Authorized User
 
Join Date: Apr 2005
Posts: 71
Thanks: 23
Thanked 0 Times in 0 Posts
Default

Hi, i am on page 308 of Beginning ASP.NET 4 by Imar Spaanjaars. On the page in question there is a submit button for the contact form. I was trying to familiarise myself further with CSS by positioning the button center or right using CSS as below,

Code:
 
#centerButton
{
position: "trying to set position here"; 
}
The selector type used above is the ID selector (#) which I thought would allow me to address the Button element directly via CSS, but I can't get it to work? Please note that the only values for positioning a button are Inherit, Absolute, Fixed, Relative and Static.

This started of as a general query, nothing important to get hung up on, but now I am really curious to find out why cannot apply CSS to this element.

Mark
 
Old September 18th, 2011, 02:12 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Positioning is used for different purposes than centering a button. For a detailed explanation of position take a look here:

http://www.w3schools.com/css/css_positioning.asp
http://www.barelyfitz.com/screencast...s/positioning/
http://www.google.com/#hl=en&sugexp=...q=css+position

In the contact form, the button is placed inside a table cell which you can use to center the button. Try this:

1. Assign a class (such as centered) to the td that contains the button.
2. Add the following CSS to your CSS file (from the theme for example)

Code:
 
.centered
{
  text-align: center;
}
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
markhh (September 19th, 2011)
 
Old September 19th, 2011, 03:49 AM
Authorized User
 
Join Date: Apr 2005
Posts: 71
Thanks: 23
Thanked 0 Times in 0 Posts
Default

Hi Imar, many thanks for your reply which again works spot on.

Regards
Mark





Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic Positioning zach_1988 XSLT 4 December 1st, 2008 07:45 PM
positioning issue Adam H-W CSS Cascading Style Sheets 3 January 20th, 2007 07:28 AM
Positioning Calculations rit01 ASP.NET 1.x and 2.0 Application Design 3 February 22nd, 2006 03:10 PM
Positioning Problem harpua CSS Cascading Style Sheets 5 May 27th, 2005 08:03 AM
fixed positioning mackknife BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 May 8th, 2005 10:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.