html - CSS padding only displays correctly when element is floated -
i'm having issues button not displaying correctly, when element floated left or right button displays fine, if no float applied button doesn't display correctly.
i've prepared following example demonstrate: http://codepen.io/anon/pen/xhvyt
my html , css follows:
<div class="section"> <div class="textbox"> <div class="text"> <h1>woop, title</h1> <p>content content content</p> </div> <div class="buttons"> <a href="#" id="wtf" class="button left"><span>find out more</span></a> <div class="clear"></div> </div> </div> </div> <div class="section"> <div class="textbox"> <div class="text"> <h1>woop, title</h1> <p>content content content</p> </div> <div class="buttons"> <a href="#" id="wtf" class="button middle"><span>find out more</span></a> <div class="clear"></div> </div> </div> </div> <div class="section"> <div class="textbox"> <div class="text"> <h1>woop, title</h1> <p>content content content</p> </div> <div class="buttons"> <a href="#" id="wtf" class="button right"><span>find out more</span></a> <div class="clear"></div> </div> </div> </div> css:
.section .textbox { width:25%; z-index:2; padding:2.5%; text-align: center; background: #4a8237; } .section .textbox h1 { font-weight: 800; font-size: 275%; margin:0; color:#fff; } .section .textbox .text p { margin:10% 0; color:#fff; } .section .textbox .button { width: 45%; text-align: center; background: url('http://i.imgur.com/duyp3sp.png'); border-radius: 5px; display: block; color:#fff; white-space: nowrap; } .section .textbox .button.left { float:left; } .section .textbox .button.right { float:right; } .section .textbox .button.middle { margin:0 auto; } .section .textbox .button span { display: block; min-height: 40px; padding:10%; margin-bottom:10%; background: url('http://i.imgur.com/nvjtudl.png') no-repeat center bottom; } as can see there 3 .section divs. in each ones button floated left/right displays properly, when no float applied it's span not displaying:block;
thanks in advance help.
changing "display:block" "display:inline-block" seems fix problem without concerns floats.
.section .textbox .button span { display: inline-block; min-height: 40px; padding:10%; margin-bottom:10%; background: url('http://i.imgur.com/nvjtudl.png') no-repeat center bottom; }
Comments
Post a Comment