【问题标题】:How separate 2 flex blocks with HTML and CSS?如何用 HTML 和 CSS 分离 2 个 flex 块?
【发布时间】:2018-09-06 04:48:29
【问题描述】:

我正在寻找一个水平工具栏,右侧有 4 个项目,左侧​​只有一个项目。

我的代码不起作用,我不明白为什么......

我想要“电子音乐”。在左侧,其他在右侧,但我的代码不起作用...

我使用了弹性盒子,如果解决方案很简单,我很抱歉。

你能帮帮我吗?

谢谢

@charset "UTF-8";
/* CSS Document */
body {
  margin: 0;
  font-size: 28px;
  background-color: #747474;
}


/* Style the navbar */


#navbar {
  overflow: hidden;
  background: rgba(191, 191, 191 ,0.5);
  display: flex;
  justify-content: flex-end;

}

.test:nth-child(1){
  order: 1;
  align-items: flex-start;
}
.test:nth-child(2){
  order: 4;
}
.test:nth-child(3){
  order: 3;
}
.test:nth-child(4){
  order: 2;
}
.test:nth-child(5){
  order: 5;
}
<!DOCTYPE html>
<html>

    <link rel="stylesheet" href="CSS/style2.css" />
    <link rel="shortcut icon" href="IMAGES/PNG/favicon.png" />

    <head>
        <meta charset="utf-8" />
        <title>Electrophotonique Ingenierie</title>
    </head>


    <body>

        <div class="test2">
            <div id="navbar">
              <div class="test"> <a href= "index2.html">Electrophotonique Ing.</a></div>
              <div class="test"> <a class="active" href="javascript:void(0)">Blog</a></div>
              <div class="test"> <a href="blog">Contact</a></div>
              <div class="test"> <a href="blog">L'électrophotonique</a></div>
              <div class="test"> <a href="blog">Qui sommes nous?</a></div>


            </div>

    <div class="content">

    </div>


<script type="text/javascript" src="JS/sticky_navbar.js"></script>


</body>
</html>

【问题讨论】:

    标签: javascript html css flexbox


    【解决方案1】:

    我不太确定我是否理解您的问题。这是您想要实现的目标吗:

    body {
      margin: 0;
      background-color: #747474;
      font-size:12px;
    }
    
    
    /* Style the navbar */
    
    
    #navbar {
      overflow: hidden;
      background: rgba(191, 191, 191 ,0.5);
      display: flex;
      justify-content: flex-end;
    
    }
    .test{padding:.5em 1em;}
    
    .test:nth-child(1){
      order: 1;
      margin:0 auto 0 0;
      
    }
    .test:nth-child(2){
      order: 4;
    }
    .test:nth-child(3){
      order: 3;
    }
    .test:nth-child(4){
      order: 2;
    }
    .test:nth-child(5){
      order: 5;
    }
    <div class="test2">
      <div id="navbar">
        <div class="test"> <a href="index2.html">Electrophotonique Ing.</a></div>
        <div class="test"> <a class="active" href="javascript:void(0)">Blog</a></div>
        <div class="test"> <a href="blog">Contact</a></div>
        <div class="test"> <a href="blog">L'électrophotonique</a></div>
        <div class="test"> <a href="blog">Qui sommes nous?</a></div>
    
      </div>
    
      <div class="content">
    
      </div>

    【讨论】:

      猜你喜欢
      • 2021-03-29
      • 2016-08-30
      • 2018-07-09
      • 2021-01-05
      • 1970-01-01
      • 2021-10-15
      • 1970-01-01
      • 2012-07-20
      • 1970-01-01
      相关资源
      最近更新 更多