Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 16th, 2011, 04:25 AM
Authorized User
Points: 303, Level: 6
Points: 303, Level: 6 Points: 303, Level: 6 Points: 303, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: , , United Kingdom.
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
Reply With Quote
  #2 (permalink)  
Old September 16th, 2011, 02:00 PM
Friend of Wrox
Points: 547, Level: 8
Points: 547, Level: 8 Points: 547, Level: 8 Points: 547, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
  #3 (permalink)  
Old September 18th, 2011, 01:28 PM
Authorized User
Points: 303, Level: 6
Points: 303, Level: 6 Points: 303, Level: 6 Points: 303, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: , , United Kingdom.
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
Reply With Quote
  #4 (permalink)  
Old September 18th, 2011, 02:12 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
markhh (September 19th, 2011)
  #5 (permalink)  
Old September 19th, 2011, 03:49 AM
Authorized User
Points: 303, Level: 6
Points: 303, Level: 6 Points: 303, Level: 6 Points: 303, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: , , United Kingdom.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:01 PM.


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