473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

A Truly Vertically Centred Button

42
First off, this is my first post, though TheScripts has solved gazillions of my C/PHP/SQL/HTML problems for years.You guys rock!

That said, consider the table cell

[HTML]<td> <!--Adding 'height=100' makes it easier to view; 'style="vertical-align:middle"' is default -->
<form>
<input name="button" type=button value=Go>
</form>
</td>[/HTML]

This will produce a cell with a button vertically centred, but visibly
off: the button is being centred by its baseline, not its true centre.
What CSS can be applied to truly make this button vertically centred
(i.e., the space above and below is equal)?

Also consider what happens when Line 1 is replaced with <td style="vertical-align:bottom">. White space appears between the button and the cell floor, and nothing--not margin:, not border-spacing, nothing--seems to be able to get rid of it. What can be done to make the button actually touch bottom? Perhaps this space is impacting how it centres?

Thanks!
Sep 26 '07 #1
6 2028
drhowarddrfine
7,435 Expert 4TB
To make the button touch the bottom, it's the td that's causing the space:
td{margin:0;padding:0}

vertical-align:middle looks vertically centered to me.
Sep 26 '07 #2
spamguy
42
To make the button touch the bottom, it's the td that's causing the space:
td{margin:0;padding:0}

vertical-align:middle looks vertically centered to me.
Hmmm. Your suggestion nudged it down a few pixels, but there's still a clear ~20px space between the button base and cell base.

To give you an idea of what I'm seeing, take a look at this pic. The cell on the left is vertical-align:middle; on the right, vertical-align:bottom. As you can see, both are well north of where they should be.
Sep 27 '07 #3
drhowarddrfine
7,435 Expert 4TB
[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title></title>
<style type="text/css">
td{
height:100px;
outline:1px solid red;
vertical-align:bottom;
margin:0;padding:0;
}
</style>
</head>

<body>

<table>
<tr>
<td> <!--Adding 'height=100' makes it easier to view; 'style="vertical-align:middle"' is default -->
<form>
<input name="button" type=button value=Go>
</form>
</td>
</tr>
</table>

</body>
</html>[/HTML]
Sep 27 '07 #4
spamguy
42
[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title></title>
<style type="text/css">
td{
height:100px;
outline:1px solid red;
vertical-align:bottom;
margin:0;padding:0;
}
</style>
</head>

<body>

<table>
<tr>
<td> <!--Adding 'height=100' makes it easier to view; 'style="vertical-align:middle"' is default -->
<form>
<input name="button" type=button value=Go>
</form>
</td>
</tr>
</table>

</body>
</html>[/HTML]
I was about to say there was no difference in what you supplied. When I made a precise copy, though, it worked. The magic tag?

[html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 01//EN" "http://www.worg/TR/html4/strict.dtd">[/html]

This is the first time that dumb tag has done anything useful for me. Thanks for your help!
Sep 27 '07 #5
drhowarddrfine
7,435 Expert 4TB
FF2 and IE6. Post your markup or show a link.
Sep 27 '07 #6
spamguy
42
(Above post edited with solution.)
Sep 27 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Lyn | last post by:
Hi, I have a form which is opened from a button on another form. The form is used to display a list of records from a recordset in Continuous Mode. It is sized vertically to display about 25...
6
by: martin.eyles | last post by:
I am having a problem with this page:- http://www.bytronic.com/tests/centre.html I want a nice centred paragraph, but get a justified paragraph. I expected the .centre to override the #content...
17
by: Alan Silver | last post by:
Hello, If you look at http://www.kidsinaction.org.uk/Thumbs.html you will see a simplified version of a page that could be used to display thumbnail images of various products. Now, due to...
4
by: Alan Silver | last post by:
Suppose I have a div that contains the content of my page. I would like to have this div centred in the browser, with a (say) 10px margin on either side. So far, no problem... (WARNING - the HTML...
4
by: Alan Silver | last post by:
Hello, Please pardon what is probably a dumb question, but if I have HTML like this... <div> <h3>Ferrets</h3> </div> and CSS like this...
1
by: Socrates | last post by:
Hi - Have tried for half and hour to get this script to work: I am trying to close the parent window while opening a centred new child window I would be grateful if someone could correct the...
4
by: Greg Scharlemann | last post by:
I'm having difficulty getting the radio buttons to align vertically with one another and the header (1 2 3 4 5) at the top. Ideally each radio button will be directly below the one above it and...
0
by: william.oram | last post by:
Consider the table cell <td<!--Adding 'height=100 style="vertical-align:middle"' makes it easier to view --> <form> <input name="button" type=button value=Go> </form> </td> This will...
1
by: Maxime | last post by:
Hello, I want to make a button that automatically resizes according to the text length and the font size (which can be changed in firefox pretty easily with the browser). The button already...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.