I've created some floating buttons and a link that fills the whole button. However, vertical alignment doesn't seem to apply - the link text always stays at the top of the button <li>
.
Here's a fiddle example: http://jsfiddle.net/su7nf/
<div id="ButtonContainer">
<ul>
<li>
<div class="TemplateButton"><a href="http://www.google.com">Report an Issue</a></div>
</li>
<li>
<div class="TemplateButton"><a href="http://www.google.com">Contact Us</a></div>
</li>
<li>
<div class="TemplateButton"><a href="http://www.google.com">Enter Project</a></div>
</li>
<li>
<div class="TemplateButton"><a href="http://www.google.com">Request Consultation</a></div>
</li>
<li>
<div class="TemplateButton"><a href="http://www.google.com">How to Protect Yourself From Some Really Long Text</a></div>
</li>
</ul>
</div>
ul {
list-style-type: none;
}
/* BUTTONS INSIDE TAB STYLING */
#ButtonContainer {
margin: auto;
width: 100%;
overflow: auto;
padding-top: 10px;
padding-bottom: 10px;
}
#ButtonContainer > ul {
padding: 0;
margin: 0;
}
#ButtonContainer > ul > li {
display: inline-block;
vertical-align: bottom;
}
.TemplateButton {
overflow: auto;
vertical-align: bottom;
}
.TemplateButton > a {
width: 119px;
height: 119px;
padding: 15px;
float: left;
background-color: pink;
margin-left: 3px;
margin-right: 3px;
vertical-align: bottom;
text-align: center;
font-size: 1.25em;
border: 1px solid white;
border-radius: 15px;
-moz-border-radius: 15px;
}
Set the anchor's line-height
to that of the DIV, or set it to display: block
otherwise your width/height values won't work
In your a
tags use table-cell
instead of float
and change vertical-align to middle
:
.TemplateButton > a {
/*float: left; Remove this*/
display:table-cell; /*Add this*/
vertical-align:middle; /*Change to middle*/
}
Check this Demo Fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With