html - float 元素下的按钮对齐

标签 html css

请参阅未对齐按钮的附图 enter image description here

CSS 和 html 是:

<div class="row">
<div class="col-lg-10">
    <div class="athlete-image">
        <img src="{{ url('assets/img/profile.png') }}" class="img-circle img-responsive img-center">
    </div>                      
    <div class="info-pad">
        <div class="athlete-name">
            <h4>{{ $an_athlete->name }} {{ $an_athlete->surname }}</h4>    
        </div>
        <div class="athlete-info">
            <p><i class="fa fa-phone athlete-info-icon" aria-hidden="true"></i> {{ $an_athlete->cellphone }}</p>
            <p><i class="fa fa-male athlete-info-icon" aria-hidden="true"></i> {{ $an_athlete->gender }}</p>
            <p><i class="fa fa-female athlete-info-icon" aria-hidden="true"></i> {{ $an_athlete->gender }}</p>
        </div>
        <div class="action-btns">
            <a href="{{ route('admin.edit_athlete', ['athlete' => $an_athlete->id]) }}" class="btn btn-labeled btn-info">
                <span class="btn-label"><i class="fa fa-pencil"></i></span>Edit Profile</a>
            <a href="{{ route('admin.test_athlete', ['athlete' => $an_athlete->id]) }}" class="btn btn-labeled btn-info" role="button">
                <span class="btn-label"><i class="fa fa-heartbeat"></i></span>Create New Test Day</a>
        </div>
    </div>                       
</div>

.athlete-image {
max-height:100px;
max-width:100px;
overflow:hidden;
padding-top: 10px;
padding-left: 10px;
margin-bottom: 20px;
float: left;
}

.info-pad {
 margin-left: 15px;
 float: left;
}

.athlete-name {
 margin-top: 5px;    
}

.athlete-info {
 display: inline-block;
 float: left;
}

.athlete-info > p {
 font-size: 14px;
 color: #666666;    
 float: left;
 padding-right: 12px;
 display: inline-block;    
}

.action-btns{
 padding: 15px 0px;    
}

我试过添加 <div style="clear: both;"></div>在操作按钮之后,包括 float: left在 Action 按钮 CSS 中。没有帮助。 如果我缩短按钮标签,它会正常工作并正确对齐。 问题:为什么两个蓝色按钮不是挨着的?

最佳答案

您必须使用 clear:both 来清除 float 元素。
只需添加以下CSS即可解决此问题

.action-btns{
  padding: 15px 0px;    
  clear: both;
}

关于html - float 元素下的按钮对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43611319/

相关文章:

html - 居中图像 int float div

javascript - 刷新后没有CSS

html - wrapper div 的宽度和 content right 的宽度应根据 content right 中的内容增加

html - 如何启动没有工具栏的新浏览器窗口?

javascript - 在有序的单词序列中 : "Word1, Word2, Word3": how to have 1 and only 1 hyperlink on "Word1" & "Word3"? 因此,在单个链接中跳过一个单词?

javascript - 从网页上的 php 调用的 html 和 div 添加的 Jquery 函数无法正常工作

来自父 div 的可变宽度的 CSS 水平菜单

css 规则在 iOS9 上不能正常工作

html - 我的页脚未对齐,需要修复才能位于中心

php - HTML "name"属性中可以使用非西方字符吗?