Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在ionic 4中使用css将时间线居中 我不是一个CSS专家,我发现了一个由CSS和HTML构建的时间线模板,我想在我的离子应用程序中使用它,问题是时间线显示在卡(页)的中间,但是我想把它显示在卡片左边(页面),有人能帮助吗?_Html_Css_Ionic Framework - Fatal编程技术网

如何在ionic 4中使用css将时间线居中 我不是一个CSS专家,我发现了一个由CSS和HTML构建的时间线模板,我想在我的离子应用程序中使用它,问题是时间线显示在卡(页)的中间,但是我想把它显示在卡片左边(页面),有人能帮助吗?

如何在ionic 4中使用css将时间线居中 我不是一个CSS专家,我发现了一个由CSS和HTML构建的时间线模板,我想在我的离子应用程序中使用它,问题是时间线显示在卡(页)的中间,但是我想把它显示在卡片左边(页面),有人能帮助吗?,html,css,ionic-framework,Html,Css,Ionic Framework,图像如下所示: 但我想要的结果是: Html代码: <ion-card> <ion-card-header> <ion-card-subtitle>Card Subtitle</ion-card-subtitle> <ion-card-title>Card Title</ion-card-title> </ion-card-header> <ion-card-conten

图像如下所示:

但我想要的结果是:

Html代码:

 <ion-card>
  <ion-card-header>
    <ion-card-subtitle>Card Subtitle</ion-card-subtitle>
    <ion-card-title>Card Title</ion-card-title>
  </ion-card-header>

  <ion-card-content>
    <div>
    <ul class="timeline">

      <!-- Item 1 -->
      <li>
        <div class="direction-r">
          <div class="flag-wrapper">
            <span class="flag">Freelancer</span>
            <span class="time-wrapper"><span class="time">2013 - present</span></span>
          </div>

        </div>
      </li>

      <!-- Item 2 -->
      <li>
        <div class="direction-r">
          <div class="flag-wrapper">
            <span class="flag">Apple Inc.</span>
            <span class="time-wrapper"><span class="time">2011 - 2013</span></span>
          </div>

        </div>
      </li>

      <!-- Item 3 -->
      <li>
        <div class="direction-r">
          <div class="flag-wrapper">
            <span class="flag">Harvard University</span>
            <span class="time-wrapper"><span class="time">2008 - 2011</span></span>
          </div>

        </div>
      </li>

    </ul>
  </div>
  </ion-card-content>
</ion-card>

删除
页边距:0自动
。时间线

.timeline {
    position: relative;
    width: 660px;
    /*margin: 0 auto;*/ /*Remove this*/
    margin-top: 20px;
    padding: 1em 0;
    list-style-type: none;
    }

删除
页边距:0自动
。时间线

.timeline {
    position: relative;
    width: 660px;
    /*margin: 0 auto;*/ /*Remove this*/
    margin-top: 20px;
    padding: 1em 0;
    list-style-type: none;
    }

我希望这是你所期待的。 变化:

然后删除所有媒体查询

只需使用修改后的css:

.timeline {
  position: relative;
  width: 350px;
  margin-top: 20px;
  padding: 1em 0;
  list-style-type: none;
}

.timeline:before {
  position: absolute;
  left: 20px;
  top: 0;
  content: " ";
  display: block;
  width: 6px;
  height: 100%;
  margin-left: -3px;
  background: rgb(80, 80, 80);
  background: -moz-linear-gradient( top, rgba(80, 80, 80, 0) 0%, rgb(80, 80, 80) 8%, rgb(80, 80, 80) 92%, rgba(80, 80, 80, 0) 100%);
  background: -webkit-gradient( linear, left top, left bottom, color-stop(0%, rgba(30, 87, 153, 1)), color-stop(100%, rgba(125, 185, 232, 1)));
  background: -webkit-linear-gradient( top, rgba(80, 80, 80, 0) 0%, rgb(80, 80, 80) 8%, rgb(80, 80, 80) 92%, rgba(80, 80, 80, 0) 100%);
  background: -o-linear-gradient( top, rgba(80, 80, 80, 0) 0%, rgb(80, 80, 80) 8%, rgb(80, 80, 80) 92%, rgba(80, 80, 80, 0) 100%);
  background: -ms-linear-gradient( top, rgba(80, 80, 80, 0) 0%, rgb(80, 80, 80) 8%, rgb(80, 80, 80) 92%, rgba(80, 80, 80, 0) 100%);
  background: linear-gradient( to bottom, rgba(80, 80, 80, 0) 0%, rgb(80, 80, 80) 8%, rgb(80, 80, 80) 92%, rgba(80, 80, 80, 0) 100%);
  z-index: 5;
}

.timeline li {
  padding: 1em 0;
}

.timeline li:after {
  content: "";
  display: block;
  height: 0;
  clear: both;
  visibility: hidden;
}

.direction-l {
  position: relative;
  width: 300px;
  float: left;
  text-align: right;
}

.direction-r {
  position: relative;
  width: 300px;
  float: right;
}

.flag-wrapper {
  position: relative;
  display: inline-block;
  text-align: center;
}

.flag {
  position: relative;
  display: inline;
  background: rgb(248, 248, 248);
  padding: 6px 10px;
  border-radius: 5px;
  font-weight: 600;
  text-align: left;
}

.direction-l .flag {
  -webkit-box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
  -moz-box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
  box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
}

.direction-r .flag {
  -webkit-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
  -moz-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
  box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
}

.direction-l .flag:before,
.direction-r .flag:before {
  position: absolute;
  top: 50%;
  right: -40px;
  content: " ";
  display: block;
  width: 12px;
  height: 12px;
  margin-top: -10px;
  background: #fff;
  border-radius: 10px;
  border: 4px solid rgb(255, 80, 80);
  z-index: 10;
}

.direction-r .flag:before {
  left: -40px;
}

.direction-l .flag:after {
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  height: 0;
  width: 0;
  margin-top: -8px;
  border: solid transparent;
  border-left-color: rgb(248, 248, 248);
  border-width: 8px;
  pointer-events: none;
}

.direction-r .flag:after {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  height: 0;
  width: 0;
  margin-top: -8px;
  border: solid transparent;
  border-right-color: rgb(248, 248, 248);
  border-width: 8px;
  pointer-events: none;
}

.time-wrapper {
  display: inline;
  line-height: 1em;
  font-size: 0.66666em;
  color: rgb(250, 80, 80);
  vertical-align: middle;
}

.direction-l .time-wrapper {
  float: left;
}

.direction-r .time-wrapper {
  float: right;
}

.time {
  display: inline-block;
  padding: 4px 6px;
  background: rgb(248, 248, 248);
}

.desc {
  margin: 1em 0.75em 0 0;
  font-size: 0.77777em;
  font-style: italic;
  line-height: 1.5em;
}

.direction-r .desc {
  margin: 1em 0 0 0.75em;
}
。时间线{
位置:相对位置;
宽度:350px;
边缘顶部:20px;
填充:1em 0;
列表样式类型:无;
}
.时间表:之前{
位置:绝对位置;
左:20px;
排名:0;
内容:“;
显示:块;
宽度:6px;
身高:100%;
左边距:-3px;
背景:rgb(80,80,80);
背景:moz线性梯度(顶部,rgba(80,80,80,0)0%,rgb(80,80,80)8%,rgb(80,80,80)92%,rgba(80,80,80,0)100%);
背景:-webkit渐变(线性,左上,左下,颜色停止(0%,rgba(30,87,153,1)),颜色停止(100%,rgba(125,185,232,1));
背景:webkit线性梯度(顶部,rgba(80,80,80,0)0%,rgb(80,80,80)8%,rgb(80,80,80)92%,rgba(80,80,80,0)100%);
背景:-o-线性梯度(顶部,rgba(80,80,80,0)0%,rgb(80,80,80)8%,rgb(80,80,80)92%,rgba(80,80,80,0)100%);
背景:-ms线性梯度(顶部,rgba(80,80,80,0)0%,rgb(80,80,80)8%,rgb(80,80,80)92%,rgba(80,80,80,0)100%);
背景:线性梯度(至底部,rgba(80,80,80,0)0%,rgb(80,80,80)8%,rgb(80,80,80)92%,rgba(80,80,80,0)100%);
z指数:5;
}
李先生{
填充:1em 0;
}
.李:之后{
内容:“;
显示:块;
身高:0;
明确:两者皆有;
可见性:隐藏;
}
.方向-l{
位置:相对位置;
宽度:300px;
浮动:左;
文本对齐:右对齐;
}
.方向-r{
位置:相对位置;
宽度:300px;
浮动:对;
}
.国旗包装纸{
位置:相对位置;
显示:内联块;
文本对齐:居中;
}
.国旗{
位置:相对位置;
显示:内联;
背景:rgb(248248248248);
填充:6px 10px;
边界半径:5px;
字号:600;
文本对齐:左对齐;
}
.方向-l.旗{
-webkit盒阴影:-1px 1px 1px rgba(0,0,0,0.15),0,0 1px rgba(0,0,0,0.15);
-莫兹盒阴影:-1px1px1pRGBA(0,0,0,0.15),0,0 1pRGBA(0,0,0,0.15);
盒影:-1px1px1pRGBA(0,0,0,0.15),0,0 1pRGBA(0,0,0,0.15);
}
.方向-r.旗{
-webkit盒阴影:1px 1px 1px rgba(0,0,0,0.15),0,0 1px rgba(0,0,0,0.15);
-moz盒阴影:1px1px1pRGBA(0,0,0,0.15),0,0 1pRGBA(0,0,0,0.15);
盒影:1px1px1pxRGBA(0,0,0,0.15),0,0 1pxRGBA(0,0,0,0.15);
}
.方向-l.标志:在,
.方向-r.标志:前{
位置:绝对位置;
最高:50%;
右:-40px;
内容:“;
显示:块;
宽度:12px;
高度:12px;
利润上限:-10px;
背景:#fff;
边界半径:10px;
边框:4倍实心rgb(255,80,80);
z指数:10;
}
.方向-r.标志:前{
左:-40px;
}
.方向-l.标志:后{
内容:“;
位置:绝对位置;
左:100%;
最高:50%;
身高:0;
宽度:0;
利润上限:-8px;
边框:实心透明;
左边框颜色:rgb(248248248248);
边框宽度:8px;
指针事件:无;
}
.方向-r.标志:后{
内容:“;
位置:绝对位置;
右:100%;
最高:50%;
身高:0;
宽度:0;
利润上限:-8px;
边框:实心透明;
右边框颜色:rgb(248248248248);
边框宽度:8px;
指针事件:无;
}
.时间包装器{
显示:内联;
线高:1米;
字体大小:0.66666em;
颜色:rgb(250,80,80);
垂直对齐:中间对齐;
}
.方向-l.时间包装器{
浮动:左;
}
.方向-r.时间包装器{
浮动:对;
}
.时间{
显示:内联块;
填充:4px6px;
背景:rgb(248248248248);
}
.描述{
保证金:1em 0.75em 0;
字体大小:0.777em;
字体:斜体;
线高:1.5em;
}
.方向-r.描述{
边缘:1em 0.75em;
}

卡片字幕
卡片标题
  • 自由职业者 2013年至今
  • 苹果公司。 2011 - 2013
  • 哈佛大学 2008 - 2011

我希望这是您所期望的。 变化:

然后删除所有媒体查询

只需使用修改后的css:

.timeline {
  position: relative;
  width: 350px;
  margin-top: 20px;
  padding: 1em 0;
  list-style-type: none;
}

.timeline:before {
  position: absolute;
  left: 20px;
  top: 0;
  content: " ";
  display: block;
  width: 6px;
  height: 100%;
  margin-left: -3px;
  background: rgb(80, 80, 80);
  background: -moz-linear-gradient( top, rgba(80, 80, 80, 0) 0%, rgb(80, 80, 80) 8%, rgb(80, 80, 80) 92%, rgba(80, 80, 80, 0) 100%);
  background: -webkit-gradient( linear, left top, left bottom, color-stop(0%, rgba(30, 87, 153, 1)), color-stop(100%, rgba(125, 185, 232, 1)));
  background: -webkit-linear-gradient( top, rgba(80, 80, 80, 0) 0%, rgb(80, 80, 80) 8%, rgb(80, 80, 80) 92%, rgba(80, 80, 80, 0) 100%);
  background: -o-linear-gradient( top, rgba(80, 80, 80, 0) 0%, rgb(80, 80, 80) 8%, rgb(80, 80, 80) 92%, rgba(80, 80, 80, 0) 100%);
  background: -ms-linear-gradient( top, rgba(80, 80, 80, 0) 0%, rgb(80, 80, 80) 8%, rgb(80, 80, 80) 92%, rgba(80, 80, 80, 0) 100%);
  background: linear-gradient( to bottom, rgba(80, 80, 80, 0) 0%, rgb(80, 80, 80) 8%, rgb(80, 80, 80) 92%, rgba(80, 80, 80, 0) 100%);
  z-index: 5;
}

.timeline li {
  padding: 1em 0;
}

.timeline li:after {
  content: "";
  display: block;
  height: 0;
  clear: both;
  visibility: hidden;
}

.direction-l {
  position: relative;
  width: 300px;
  float: left;
  text-align: right;
}

.direction-r {
  position: relative;
  width: 300px;
  float: right;
}

.flag-wrapper {
  position: relative;
  display: inline-block;
  text-align: center;
}

.flag {
  position: relative;
  display: inline;
  background: rgb(248, 248, 248);
  padding: 6px 10px;
  border-radius: 5px;
  font-weight: 600;
  text-align: left;
}

.direction-l .flag {
  -webkit-box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
  -moz-box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
  box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
}

.direction-r .flag {
  -webkit-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
  -moz-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
  box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
}

.direction-l .flag:before,
.direction-r .flag:before {
  position: absolute;
  top: 50%;
  right: -40px;
  content: " ";
  display: block;
  width: 12px;
  height: 12px;
  margin-top: -10px;
  background: #fff;
  border-radius: 10px;
  border: 4px solid rgb(255, 80, 80);
  z-index: 10;
}

.direction-r .flag:before {
  left: -40px;
}

.direction-l .flag:after {
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  height: 0;
  width: 0;
  margin-top: -8px;
  border: solid transparent;
  border-left-color: rgb(248, 248, 248);
  border-width: 8px;
  pointer-events: none;
}

.direction-r .flag:after {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  height: 0;
  width: 0;
  margin-top: -8px;
  border: solid transparent;
  border-right-color: rgb(248, 248, 248);
  border-width: 8px;
  pointer-events: none;
}

.time-wrapper {
  display: inline;
  line-height: 1em;
  font-size: 0.66666em;
  color: rgb(250, 80, 80);
  vertical-align: middle;
}

.direction-l .time-wrapper {
  float: left;
}

.direction-r .time-wrapper {
  float: right;
}

.time {
  display: inline-block;
  padding: 4px 6px;
  background: rgb(248, 248, 248);
}

.desc {
  margin: 1em 0.75em 0 0;
  font-size: 0.77777em;
  font-style: italic;
  line-height: 1.5em;
}

.direction-r .desc {
  margin: 1em 0 0 0.75em;
}
。时间线{
位置:相对位置;
宽度:350px;
边缘顶部:20px;
填充:1em 0;
列表样式类型:无;
}
.时间表:之前{
位置:绝对位置;
左:20px;
排名:0;
内容:“;
显示:块;
宽度:6px;
身高:100%;
左边距:-3px;
背景:rgb(80,80,80);
背景:moz线性梯度(顶部,rgba(80,80,80,0)0%,rgb(80,80,80)8%,rgb(80,80,80)92%,rgba(80,80,80,0)100%);
背景:-webkit渐变(线性,左上,左下,颜色停止(0%,rgba(30,87,153,1)),颜色停止(100%,rgba(125,185,232,1));
背景:webkit线性梯度(顶部,rgba(80,80,80,0)0%,rgb(80,80,80)8%,rgb(80,80,80)92%,rgba(80,80,80,0)100%);
背景:-o-线性梯度(顶部,rgba(80,80,80,0)0%,rgb(80,80,80)8%,rgb(80,80,80)92%,rgba(80,80,80,0)100%);
背景:-ms线性梯度(顶部,rgba(80,80,80,0)0%,rgb(80,80,80)8%,rgb(80,80,80)92%,rgba(80,80,80,0)100%);
背景:线性梯度(至底部,rgba(80,80,80,0)0%,rgb(80,80,80)8%,rgb(80,80,80)92%,rgba(80,80,80,0)100%);
z指数:5;
}
李先生{
填充:1em 0;
}