This question already has answers here:
My inline-block elements are not lining up properly
                                
                                    (5个答案)
                                
                        
                                4年前关闭。
            
                    
我在将相对内联块与同一行中不相对的一些内联块对齐时遇到问题。为了清楚起见,图片:


我已经尝试了一些方法(padding-top,margin-top)使这个家伙稍微下降甚至没有成功。

相关的HTML:

     <div class="course-item" ng-repeat="course in courses">
         <div class="course-title" ng-click="launchCourse(course.id)">{{course.title}}</div>
         <div class="course-grade" ng-click="launchGradebook(course.id)"><div class="course-grade-pop">{{course.grade}}</div></div>
         <div class="course-atten">{{course.attendance}}</div> <br />
     </div>


相关CSS:

.course-item
{
    margin-top: 15px;
    font-size: 14pt;
    line-height: 40px;
}
.course-title
{
    display: inline-block;
    cursor: pointer;
    text-align: left;
    text-overflow: ellipsis;
    width: 60%;
    background-color: #EEE;
    border-radius: 4px;
    padding-left: 6px;
}
.course-grade
{
    position:relative;
    display: inline-block;
    cursor: pointer;
    text-align: center;
    font-size: 15pt;
    width: 18%;
    height: 40px;
    padding-top: 10px;
    background-color: #EEE;
    border-radius: 4px;
    margin-left: 2%;
}
.course-atten
{
    display: inline-block;
    text-align: center;
    font-size: 15pt;
    width: 18%;
    background-color: #EEE;
    border-radius: 4px;
    margin-left: 2%;
}
.course-grade-pop
{
    position: absolute;
    top: 0px;
    left: 0px;
    height: 100%;
    width: 100%;
    border-radius: 4px;
}


关于如何使块与其他块坐在同一行上的任何想法吗?

最佳答案

您只需将vertical-align:bottom添加到.course-grade即可解决此问题

09-16 07:27