Reputation: 313
I have a problem I just can't seem to solve, I just began learning html/css/php, thus please understand my rookie-ness :)
So imagine a website, on that website you have 8 buttons (each being a specific choice).
I wan't to position them equally below and aside each other. So something like this:
[] []
[] []
[] []
[] []
But my problem is, when I give up the css style position, the button do take that specific position, however the href of the buttons won't work anymore. What is the problem?
Is there perhaps a way to put top and right in the .btn class? I don't think so because I want the 8 button's to have different positions. I think the "style="top; right;" is interfering with the class.
<html>
<head>
<style type="text/css">
body{
background-image: url("images/bg.jpg");
background-color: #844903;
}
.logo{
position: absolute;
top: 40px;
right: 850px;
}
h1{
position: absolute;
top: 250px;
right: 870px;
color: #a86b00;
}
.btn {
-moz-box-shadow:inset 0px 1px 0px 0px #fce2c1;
-webkit-box-shadow:inset 0px 1px 0px 0px #fce2c1;
box-shadow:inset 0px 1px 0px 0px #fce2c1;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ffc477), color-stop(1, #fb9e25));
background:-moz-linear-gradient(top, #ffc477 5%, #fb9e25 100%);
background:-webkit-linear-gradient(top, #ffc477 5%, #fb9e25 100%);
background:-o-linear-gradient(top, #ffc477 5%, #fb9e25 100%);
background:-ms-linear-gradient(top, #ffc477 5%, #fb9e25 100%);
background:linear-gradient(to bottom, #ffc477 5%, #fb9e25 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffc477', endColorstr='#fb9e25',GradientType=0);
background-color:#ffc477;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #eeb44f;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Courier New;
font-size:20px;
font-weight:bold;
padding:17px 24px;
text-decoration:none;
text-shadow:0px 1px 0px #cc9f52;
}
.btn:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #fb9e25), color-stop(1, #ffc477));
background:-moz-linear-gradient(top, #fb9e25 5%, #ffc477 100%);
background:-webkit-linear-gradient(top, #fb9e25 5%, #ffc477 100%);
background:-o-linear-gradient(top, #fb9e25 5%, #ffc477 100%);
background:-ms-linear-gradient(top, #fb9e25 5%, #ffc477 100%);
background:linear-gradient(to bottom, #fb9e25 5%, #ffc477 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fb9e25', endColorstr='#ffc477',GradientType=0);
background-color:#fb9e25;
}
.btn:active {
position:relative;
top:1px;
</style>
<title></title>
</head>
<body>
<h1>Please pick a location:</h1>
<div class="logo"><img src="images/logo.jpg" alt="logo"></div>
<table>
<tr>
<td style="top: 450px; right: 1200px;" href="#" class="btn">1 - 3</td>
</tr>
<tr>
<td style="top: 450px; right: 1050px;" href="#" class="btn">4 - 6</td>
</tr>
<tr>
<td style="top: 540px; right: 1200px;" href="#" class="btn">7 - 9</td>
</tr>
<tr>
<td style="top: 540px; right: 1050px;" href="#" class="btn">10+</td>
</tr>
</table>
</body>
</html>
Thank you very much for your time!
-M
Upvotes: 1
Views: 1444
Reputation: 313
@odedta:
It seems very logical what you have shown, however when I try it, it bunches-up my buttons:
<table>
<tr>
<td><button class="btn"><a href="participants.html">Table 2</a></button></td>
<td><button class="btn"><a href="participants.html">Table 4</a></button></td>
</tr>
<tr>
<td><button class="btn"><a href="participants.html">Table 7</a></button></td>
<td><button class="btn"><a href="participants.html">Table 8</a></button></td>
</tr>
<tr>
<td><button class="btn"><a href="participants.html">F1.12</a></button></td>
<td><button class="btn"><a href="participants.html">F3.02</a></button></td>
</tr>
<tr>
<td><button class="btn"><a href="participants.html">E2.40</a></button></td>
<td><button class="btn"><a href="participants.html">E2.42</a></button></td>
</tr>
</table>
Upvotes: 0
Reputation: 1120
try using display:block
and display display:inline-block
. second you should use <a>
tag. put an <a>
tag inside a <td>
tag with href
property . something like <td><a href="#">7</a></td>
Upvotes: 0
Reputation: 2478
<table>
<tr>
<td><button><a href="#">1</a></button></td>
<td><button><a href="#">2</a></button></td>
</tr>
<tr>
<td><button><a href="#">3</a></button></td>
<td><button><a href="#">4</a></button></td>
</tr>
<tr>
<td><button><a href="#">5</a></button></td>
<td><button><a href="#">6</a></button></td>
</tr>
<tr>
<td><button><a href="#">7</a></button></td>
<td><button><a href="#">8</a></button></td>
</tr>
</table>
There you go.
EDIT: if you want the to style the buttons, give them a class or id and use that in your CSS file. i.e. You can use margins and paddings to control where your button is located.
Upvotes: 1