如何修复我的CSS,该CSS在Edge上可以正常运行,但在IE上不能

时间:2019-12-02 14:40:40

标签: html css internet-explorer microsoft-edge

我目前正在制作一个小型网页,上面有一堆带有链接的按钮。该网页在Edge上显示完美,但我不确定如何修复它以使其在IE上正常显示。当前,按钮和导航栏太大了,彼此重叠。

.header img {
    float: left;
    width: 100px;
    height: 100px;
  }

  .header h1 {
    position: relative;
    top: 18px;
    left: 10px;
    font-size: 300%;
  }
  body {
    background-color: lightblue;
  }
  .container {
    display: grid;
  }

  .nav-bar {
    display: grid;
    grid-template-columns: 16.6% 16.6% 16.6% 16.6% 16.6% 16.6%;
    justify-content: space-around;
    color: white;
    background-color: black;
    height: 40px;
    align-items: center;
    font-size: 20px;
  }

  .nav-item {
    text-align: center;
  }

  .buttons {
    display: grid;
    grid-template-columns: 16.6% 16.6% 16.6% 16.6% 16.6% 16.6%;
    justify-content: space-around;
  }

  .button-group {
    display: flex;
    flex-direction: column;
  }

  button {
    border-radius: 12px;
    background-color: gray;
    color: white;
    border: none;
    margin: 5px;
    height: 50px;
    font-size: 20px;
    cursor: pointer;
  }
  button:hover{
    background-color: #4CAF50;
    color: white;
  }
  .generaldocs{
    margin-left: 50px;
    margin-top: 10px;
  }
  .technews{
    margin-left: 90px;
    margin-top: 10px;
  }

  .nav-item a{
    color: white;
    text-decoration: none;
  }
  .header a{
    text-decoration: none;
    color: black;
  }

1 个答案:

答案 0 :(得分:1)

尝试使用此代码,IE和一些旧的浏览器需要前缀才能正确运行代码。

.header img {
    float: left;
    width: 100px;
    height: 100px;
  }

  .header h1 {
    position: relative;
    top: 18px;
    left: 10px;
    font-size: 300%;
  }
  body {
    background-color: lightblue;
  }
  .container {
    display: grid;
  }

  .nav-bar {
    display: grid;
    grid-template-columns: 16.6% 16.6% 16.6% 16.6% 16.6% 16.6%;
    -ms-flex-pack: distribute;
    justify-content: space-around;
    color: white;
    background-color: black;
    height: 40px;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    font-size: 20px;
  }

  .nav-item {
    text-align: center;
  }

  .buttons {
    display: grid;
    grid-template-columns: 16.6% 16.6% 16.6% 16.6% 16.6% 16.6%;
    -ms-flex-pack: distribute;
    justify-content: space-around;
  }

  .button-group {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
  }

  button {
    border-radius: 12px;
    background-color: gray;
    color: white;
    border: none;
    margin: 5px;
    height: 50px;
    font-size: 20px;
    cursor: pointer;
  }
  button:hover{
    background-color: #4CAF50;
    color: white;
  }
  .generaldocs{
    margin-left: 50px;
    margin-top: 10px;
  }
  .technews{
    margin-left: 90px;
    margin-top: 10px;
  }

  .nav-item a{
    color: white;
    text-decoration: none;
  }
  .header a{
    text-decoration: none;
    color: black;
  }