我试图通过CSS添加一个白色箭头到链接按钮的底部.但是,我无法统一所有按钮的箭头中心..
HTML:
<div class="help-buttons"> <a href="#" class="help-button">User information</a> <a href="#" class="help-button">Company information</a> <a href="#" class="help-button">Driver information</a> </div>
CSS:
.help-buttons { margin: 75px auto; text-align: center; } .help-button { background: #1795db; color: #fff; padding: 15px 20px; font-family: 'Open sans'; Box-shadow: 3px 3px 0px 0px rgba(0,0.2); margin: 0 30px; } .help-button:after { content: ""; position: absolute; margin-top: 25px; margin-left: -75px; width: 0; height: 0; border-left: 13px solid transparent; border-right: 13px solid transparent; border-bottom: 13px solid #ffffff; }
解决方法
> Make .help-button position:relative;这样箭头就相对于按钮定位了.
>负边距:之后应与边框大小相同.
>调整底部:-6px以获得您想要的尺寸.
>负边距:之后应与边框大小相同.
>调整底部:-6px以获得您想要的尺寸.
HTML
<div class="help-buttons"> <a href="#" class="help-button">User information</a> <a href="#" class="help-button">Company information</a> <a href="#" class="help-button">Driver information</a> </div>
CSS
.help-buttons { margin: 75px auto; text-align: center; } .help-button { background: #1795db; color: #fff; padding: 15px 20px; font-family: 'Open sans'; Box-shadow: 3px 3px 0px 0px rgba(0,0.2); margin: 0 30px; position: relative; } .help-button:after { content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -13px; width: 0; height: 0; border-left: 13px solid transparent; border-right: 13px solid transparent; border-bottom: 13px solid #ffffff; }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。