.main-timeline10 .timeline:nth-child(1) .timeline-inner:after {
background: #58b25e;
width: 50px;
}
:after
,是否可以为此添加宽度?$(".main-timeline10.timeline:nth-child(1).timeline-inner:after").css("width","100%")
,但没有用 Update
根据下面的建议,我检查了link是否为接受的答案。
遇到错误
//$('.main-timeline10.timeline:nth-child(1).timeline-inner').attr("style","width:100%");
$('.main-timeline10 .timeline-inner').addClass('changewidth').attr('data-width','100%');
.changewidth:after {
width: attr(data-width);
}
a {
text-decoration: none
}
h4 {
text-align: center;
margin: 30px 0;
color: #444
}
.main-timeline10:after,
.main-timeline10:before {
content: "";
display: block;
width: 100%;
clear: both
}
.main-timeline10 .timeline {
padding: 0;
display: -webkit-inline-box;
}
.main-timeline10 {
display: flex;
min-height: 750px;
}
.main-timeline10 .col-md-3 {
-ms-flex: 0 0 20%;
flex: 0 0 20%;
max-width: 30%;
/* max-width: 24%; */
align-self: flex-end;
display: flex;
}
.main-timeline10 .timeline-inner {
text-align: center;
margin: 0px 0px 17px 30px;
/* margin: 20px 20px 35px 35px; */
position: relative;
}
.main-timeline10 .timeline:nth-child(1) .timeline-inner:after {
background: #58b25e;
width: 50px;
}
.main-timeline10 .timeline:nth-child(2) .timeline-inner:after {
background: #9f84c4;
width: 0;
}
.main-timeline10 .timeline:nth-child(3) .timeline-inner:after {
background: #f35958;
width: 0;
}
.main-timeline10 .timeline:nth-child(4) .timeline-inner:after {
background: #e67e49;
width: 0;
}
.main-timeline10 .timeline .timeline-inner:after {
content: "";
background: #555;
}
.main-timeline10 .timeline-inner:after {
/* .col-md-3.col-sm-6.timeline{ */
/* width: 120%; */
width: 100%;
height: 6px;
/* background: #58b25e;#555; */
position: absolute;
bottom: 0;
left: 10%
}
.main-timeline10 .timeline:last-child .timeline-inner:after {
width: 0
}
.main-timeline10 .tier {
background: #58b25e;
padding: 5px 30px;
border-radius: 30px 0;
font-size: 18px;
font-weight: 700;
color: #fff;
z-index: 1;
position: relative
}
.main-timeline10 .tier:after,
.main-timeline10 .tier:before {
position: absolute;
top: -19px;
content: ""
}
.main-timeline10 .tier:before {
right: 0;
border: 10px solid transparent;
border-bottom: 10px solid #58b25e;
border-right: 10px solid #58b25e
}
.main-timeline10 .tier:after {
width: 25px;
height: 19px;
border-radius: 0 0 20px;
background: #fff;
right: 1px
}
.main-timeline10 .timeline-content {
padding: 10px 10px 30px;
border-left: 3px solid #58b25e;
position: relative
}
.main-timeline10 .timeline-content:before {
content: "";
position: absolute;
top: 0;
left: -1px;
border: 10px solid transparent;
border-top: 10px solid #58b25e;
border-left: 10px solid #58b25e
}
.main-timeline10 .timeline-content:after {
content: "";
width: 25px;
height: 19px;
border-radius: 20px 0 0;
background: #fff;
position: absolute;
top: 0;
left: 0
}
.main-timeline10 .post {
/* font-size: 26px; */
font-size: 12px;
color: #333
}
.main-timeline10 .description {
font-size: 14px;
color: #333
}
.main-timeline10 .timeline-icon {
width: 70px;
height: 70px;
line-height: 65px;
border-radius: 50%;
border: 5px solid #58b25e;
background: #fff;
font-size: 30px;
color: #555;
z-index: 1;
position: absolute;
bottom: -35px;
left: -35px
}
.main-timeline10 .col-md-3.timeline:nth-child(1n) .timeline-content {
min-height: 20%;
}
.main-timeline10 .col-md-3.timeline:nth-child(2n) .timeline-content {
min-height: 380px;
max-height: 440px;
}
.main-timeline10 .col-md-3.timeline:nth-child(3n) .timeline-content {
min-height: 460px;
max-height: 520px;
}
.main-timeline10 .col-md-3.timeline:nth-child(4n) .timeline-content {
min-height: 520px;
max-height: 580px;
}
.main-timeline10 .col-md-3.timeline:nth-child(5n) .timeline-content {
min-height: 600px;
}
.timeline-content {
overflow: auto;
}
.main-timeline10 .timeline:nth-child(2n) .tier {
background: #9f84c4
}
.main-timeline10 .timeline:nth-child(2n) .tier:before {
border-bottom-color: #9f84c4;
border-right-color: #9f84c4
}
.main-timeline10 .timeline:nth-child(2n) .timeline-content {
border-left-color: #9f84c4
}
.main-timeline10 .timeline:nth-child(2n) .timeline-content:before {
border-top-color: #9f84c4;
border-left-color: #9f84c4
}
.main-timeline10 .timeline:nth-child(2n) .timeline-icon {
border-color: #9f84c4
}
.main-timeline10 .timeline:nth-child(3n) .tier {
background: #f35958
}
.main-timeline10 .timeline:nth-child(3n) .tier:before {
border-bottom-color: #f35958;
border-right-color: #f35958
}
.main-timeline10 .timeline:nth-child(3n) .timeline-content {
border-left-color: #f35958
}
.main-timeline10 .timeline:nth-child(3n) .timeline-content:before {
border-top-color: #f35958;
border-left-color: #f35958
}
.main-timeline10 .timeline:nth-child(3n) .timeline-icon {
border-color: #f35958
}
.main-timeline10 .timeline:nth-child(4n) .tier {
background: #e67e49
}
.main-timeline10 .timeline:nth-child(4n) .tier:before {
border-bottom-color: #e67e49;
border-right-color: #e67e49
}
.main-timeline10 .timeline:nth-child(4n) .timeline-content {
border-left-color: #e67e49
}
.main-timeline10 .timeline:nth-child(4n) .timeline-content:before {
border-top-color: #e67e49;
border-left-color: #e67e49
}
.main-timeline10 .timeline:nth-child(4n) .timeline-icon {
border-color: #e67e49
}
.main-timeline10 .timeline:nth-child(5n) .tier {
background: #275959
}
.main-timeline10 .timeline:nth-child(5n) .tier:before {
border-bottom-color: #275959;
border-right-color: #275959
}
.main-timeline10 .timeline:nth-child(5n) .timeline-content {
border-left-color: #275959
}
.main-timeline10 .timeline:nth-child(5n) .timeline-content:before {
border-top-color: #275959;
border-left-color: #275959
}
.main-timeline10 .timeline:nth-child(5n) .timeline-icon {
border-color: #275959
}
.timeline-inner {
width: 100%
}
@media only screen and (max-width:990px) {
.main-timeline10 .timeline-inner:after {
width: 110%
}
.main-timeline10 .timeline .timeline-inner:after {
width: 0
}
}
@media only screen and (max-width:767px) {
.main-timeline10 .timeline {
margin-bottom: 50px
}
.main-timeline10 .timeline-inner:after,
.main-timeline10 .timeline .timeline-inner:after {
width: 100%;
height: 3px;
left: 0
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<div class="container">
<h4>Timeline Style : Demo-10</h4>
<div class="row">
<div class="main-timeline10">
<div class="col-md-3 col-sm-6 timeline">
<div class="timeline-inner">
<div class="tier">Rank 1</div>
<div class="timeline-content">
</div>
<div class="timeline-icon">
<i class="fas fa-project-diagram"></i>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 timeline">
<div class="timeline-inner">
<div class="tier">Rank 2</div>
<div class="timeline-content">
</div>
<div class="timeline-icon">
<i class="fas fa-microchip"></i>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 timeline">
<div class="timeline-inner">
<div class="tier">Rank 3</div>
<div class="timeline-content">
</div>
<div class="timeline-icon">
<i class="fas fa-sitemap"></i>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 timeline">
<div class="timeline-inner">
<div class="tier">Rank 4</div>
<div class="timeline-content">
</div>
<div class="timeline-icon">
<i class="fas fa-laptop-code"></i>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 timeline">
<div class="timeline-inner">
<img src="http://localhost/ilearn/assets/images/Star.gif" class="" alt="avatar" height="80" width="80">
<div class="tier">Final</div>
<div class="timeline-content">
</div>
<div class="timeline-icon">
<i class="fas fa-trophy"></i>
</div>
</div>
</div>
</div>
</div>
</div>
<hr>