如何修复CSS网格区域以在IE11中工作?

时间:2020-01-06 14:42:35

标签: html css css-grid

我已经使用CSS Grid创建了一个时间轴界面,但是随后我发现IE11中不完全支持CSS Grid。不幸的是,我需要这个才能在IE11中工作。您能告诉我问题是什么以及如何解决?我想问题出在grid-area

小提琴: https://jsfiddle.net/oL5d2ceb/

HTML:

<div class="timeline">
    <dl class="hr-guide-step">
      <dt class="hr-guide-step__title">Title A</dt>
      <dd class="hr-guide-step__text">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec
        odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi.
      </dd>
    </dl>
    <dl class="hr-guide-step">
      <dt class="hr-guide-step__title">Title A</dt>
      <dd class="hr-guide-step__text">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec
        odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi.
      </dd>
    </dl>
    <dl class="hr-guide-step">
      <dt class="hr-guide-step__title">Title A</dt>
      <dd class="hr-guide-step__text">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec
        odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi.
      </dd>
    </dl>
    <dl class="hr-guide-step">
      <dt class="hr-guide-step__title">Title A</dt>
      <dd class="hr-guide-step__text">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec
        odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi.
      </dd>
    </dl>
    <dl class="hr-guide-step">
      <dt class="hr-guide-step__title">Title A</dt>
      <dd class="hr-guide-step__text">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec
        odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi.
      </dd>
    </dl>
    <dl class="hr-guide-step">
      <dt class="hr-guide-step__title">Title A</dt>
      <dd class="hr-guide-step__text">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec
        odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi.
      </dd>
    </dl>
  </div>

CSS:

/*- Screen Sizes*/
/*import fonts*/
@import url("https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css");
@import url("https://fonts.googleapis.com/css?family=Open+Sans");
@import url("https://fonts.googleapis.com/css?family=Oswald");
/*media queries*/
html {
  box-sizing: border-box;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  background-color: #444444;
  font-family: "Open Sans", "Lucida Grande", Tahoma, Verdana, Arial, sans-serif;
  font-size: 0.875em;
  color: #212121;
  line-height: 1.5;
}

.wrapper {
  margin: 3.125em auto;
  padding: 1em 5em 1em;
  max-width: 1000px;
}

h1 {
  color: white;
  font-family: "Open Sans", "Lucida Grande", Tahoma, Verdana, Arial, sans-serif;
  text-align: center;
}

/* - &:nth-child(1) {
             grid-area: entry1;
         }
   - useful timesaver if there is a lengthy list
*/
.timeline {
  line-height: 1.5em;
  font-size: 14px;
  transition: all 0.4s ease;
  position: relative;
  counter-reset: section;
}
.timeline:before {
  content: "";
  width: 10px;
  height: 100%;
  background: #87ceeb;
  position: absolute;
  top: 0;
  left: -3.313em;
}

.hr-guide-step {
  position: relative;
  background-color: #eeeeee;
}
.hr-guide-step__title {
  color: white;
  background-color: #ec407a;
  font-family: "Oswald", Georgia, Cambria, "Times New Roman", Times, serif;
  font-weight: 300;
  font-size: 1rem;
  padding: 1em;
}
.hr-guide-step__title:before {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  position: absolute;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  left: -1em;
  border-right: 10px solid #ec407a;
}
.hr-guide-step__text {
  background-color: #dddddd;
  padding: 1em;
  margin: 0;
}
.hr-guide-step:before {
  content: "";
  font-family: "Oswald", Georgia, Cambria, "Times New Roman", Times, serif;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3em;
  height: 3em;
  background-color: #87ceeb;
  border: 0.2em solid white;
  position: absolute;
  counter-increment: section;
  content: counter(section);
  text-shadow: 0 1px 0 #424242;
  left: -4.5em;
}

@supports (display: grid) {
  @media (min-width: 768px) {
    .timeline {
      display: grid;
      grid-gap: 4.75em;
      grid-template-areas: ".  entry1" "entry2  ." ". entry3" "entry4 ." ". entry5" "entry6 .";
    }
    .timeline:before {
      left: 49.5%;
    }

    .hr-guide-step:nth-child(1) {
      grid-area: entry1;
    }
    .hr-guide-step:nth-child(2) {
      grid-area: entry2;
    }
    .hr-guide-step:nth-child(3) {
      grid-area: entry3;
    }
    .hr-guide-step:nth-child(4) {
      grid-area: entry4;
    }
    .hr-guide-step:nth-child(5) {
      grid-area: entry5;
    }
    .hr-guide-step:nth-child(6) {
      grid-area: entry6;
    }
    .hr-guide-step:nth-of-type(odd):before {
      left: -3.8em;
    }
    .hr-guide-step:nth-of-type(even):not(:nth-of-type(odd))
      .hr-guide-step__title:before {
      left: 100%;
      border-left: 10px solid #ec407a;
      border-right: 0;
    }
    .hr-guide-step:nth-of-type(even):before {
      left: 103%;
    }
  }
}

0 个答案:

没有答案