我在下面有这个HTML:
body {
font-family: "Helvetica Neue",Helvetica,Roboto,Arial,"Lucida Grande",sans-serif;
}
.primary {
padding-top: 20px;
}
.upcoming-events {
border: 1px solid #E7EAEC;
background-color: #FFF;
width: 100%;
position: relative;
}
.upcoming-events-header {
border-bottom: 1px solid #E7EAEC;
padding: 20px 10px;
color: #2F343B;
}
.upcoming-events-header-text {
display: block;
}
.upcoming-count {
font-weight: 700;
}
.event {
position: relative;
padding: 10px;
display: block;
}
.event-date-container {
height: 65px;
border-right: 1px solid #CFD4D9;
display: table-cell;
vertical-align: middle;
width: 65px;
}
.day-label {
width: 100%;
color: #00A1A1;
text-transform: uppercase;
display: block;
font-family: 'Interstate', 'Helvetica Neue', 'Helvetica', 'Arial', 'Sans-Serif';
letter-spacing: -0.2px;
font-size: 20px;
text-align: center;
font-weight: 700;
}
.date-label {
text-align: center;
font-size: 11px;
display: block;
letter-spacing: -0.1px;
color: #87909A;
width: 100%;
text-transform: uppercase;
margin-top: 2px;
line-height: 14px;
font-weight: 500;
}
.event-info-container {
}
a {
color: #085F99;
text-decoration: none;
cursor: pointer;
}

<section class="primary">
<div class="upcoming-events">
<div class="upcoming-events-header">
<div class="upcoming-events-header-text">
<span class="upcoming-count">95</span>
Games
</div>
</div>
<div class="upcoming-events-body">
<div class="event">
<div class="event-date-container">
<span class="day-label">FRI</span>
<span class="date-label">July 25</span>
</div>
<div class="event-info-container">
<a>Pittsburgh Pirates</a>
</div>
</div>
</div>
</div>
</section>
&#13;
问题是Pittsburgh Pirates
链接没有显示在右侧,而是显示在底部,如下图所示:
有人可以告诉我如何将Pittsburgh Pirates
移到右边(基本上就在那个垂直边框之后)?
答案 0 :(得分:2)
因为您没有将.event-info-container
作为表格单元格,例如event-date-container
之前的表格单元格。
使用此CSS获取所需的display ::
.event-info-container {
display: table-cell;
vertical-align: middle;
padding-left: 20px;
};
body {
font-family: "Helvetica Neue", Helvetica, Roboto, Arial, "Lucida Grande", sans-serif;
}
.primary {
padding-top: 20px;
}
.upcoming-events {
border: 1px solid #E7EAEC;
background-color: #FFF;
width: 100%;
position: relative;
}
.upcoming-events-header {
border-bottom: 1px solid #E7EAEC;
padding: 20px 10px;
color: #2F343B;
}
.upcoming-events-header-text {
display: block;
}
.upcoming-count {
font-weight: 700;
}
.event {
position: relative;
padding: 10px;
display: block;
}
.event-date-container {
height: 65px;
border-right: 1px solid #CFD4D9;
display: table-cell;
vertical-align: middle;
width: 65px;
}
.day-label {
width: 100%;
color: #00A1A1;
text-transform: uppercase;
display: block;
font-family: 'Interstate', 'Helvetica Neue', 'Helvetica', 'Arial', 'Sans-Serif';
letter-spacing: -0.2px;
font-size: 20px;
text-align: center;
font-weight: 700;
}
.date-label {
text-align: center;
font-size: 11px;
display: block;
letter-spacing: -0.1px;
color: #87909A;
width: 100%;
text-transform: uppercase;
margin-top: 2px;
line-height: 14px;
font-weight: 500;
}
.event-info-container {
display: table-cell;
vertical-align: middle;
padding-left: 20px;
}
a {
color: #085F99;
text-decoration: none;
cursor: pointer;
}
<section class="primary">
<div class="upcoming-events">
<div class="upcoming-events-header">
<div class="upcoming-events-header-text">
<span class="upcoming-count">95</span> Games
</div>
</div>
<div class="upcoming-events-body">
<div class="event">
<div class="event-date-container">
<span class="day-label">FRI</span>
<span class="date-label">July 25</span>
</div>
<div class="event-info-container">
<a>Pittsburgh Pirates</a>
</div>
</div>
</div>
</div>
</section>
答案 1 :(得分:1)
您需要将以下内容添加到css文件中。这是你可以从其他帖子中轻易找到的东西,说实话。
.event div {
display: inline-block;
}
答案 2 :(得分:1)
在容器上使用display: flex
。
body {
font-family: "Helvetica Neue",Helvetica,Roboto,Arial,"Lucida Grande",sans-serif;
}
.primary {
padding-top: 20px;
}
.upcoming-events {
border: 1px solid #E7EAEC;
background-color: #FFF;
width: 100%;
position: relative;
}
.upcoming-events-header {
border-bottom: 1px solid #E7EAEC;
padding: 20px 10px;
color: #2F343B;
}
.upcoming-events-header-text {
display: block;
}
.upcoming-count {
font-weight: 700;
}
.event {
position: relative;
padding: 10px;
display: flex;
}
.event-date-container {
height: 65px;
border-right: 1px solid #CFD4D9;
display: table-cell;
vertical-align: middle;
width: 65px;
}
.day-label {
width: 100%;
color: #00A1A1;
text-transform: uppercase;
display: block;
font-family: 'Interstate', 'Helvetica Neue', 'Helvetica', 'Arial', 'Sans-Serif';
letter-spacing: -0.2px;
font-size: 20px;
text-align: center;
font-weight: 700;
}
.date-label {
text-align: center;
font-size: 11px;
display: block;
letter-spacing: -0.1px;
color: #87909A;
width: 100%;
text-transform: uppercase;
margin-top: 2px;
line-height: 14px;
font-weight: 500;
}
.event-info-container {
padding: 22px;
}
a {
color: #085F99;
text-decoration: none;
cursor: pointer;
}
<section class="primary">
<div class="upcoming-events">
<div class="upcoming-events-header">
<div class="upcoming-events-header-text">
<span class="upcoming-count">95</span>
Games
</div>
</div>
<div class="upcoming-events-body">
<div class="event">
<div class="event-date-container">
<span class="day-label">FRI</span>
<span class="date-label">July 25</span>
</div>
<div class="event-info-container">
<a>Pittsburgh Pirates</a>
</div>
</div>
</div>
</div>
</section>