Flexbox实现根据子元素个数实现不同justify-content方式代码

代码语言:html

所属分类:布局界面

代码描述:Flexbox实现根据子元素个数实现不同justify-content方式代码

代码标签: Flexbox 根据 子元素 个数 实现 不同 justify-content

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

    <link rel="apple-touch-icon" type="image/png" href="https://cpwebassets.codepen.io/assets/favicon/apple-touch-icon-5ae1a0698dcc2402e9712f7d01ed509a57814f994c660df9f7a952f3060705ee.png" />

    <meta name="apple-mobile-web-app-title" content="CodePen">

    <link rel="shortcut icon" type="image/x-icon" href="https://cpwebassets.codepen.io/assets/favicon/favicon-aec34940fbc1a6e787974dcd360f2c6b63348d4b1f4e06c77743096d55480f33.ico" />

    <link rel="mask-icon" type="image/x-icon" href="https://cpwebassets.codepen.io/assets/favicon/logo-pin-b4b4269c16397ad2f0f7a01bcdf513a1994f4c94b8af2f191c09eb0d601762b1.svg" color="#111" />



  
  <title>Flexbox Multiple justify-content (space-between + center)</title>
    <link rel="canonical" href="https://codepen.io/aPinix/pen/GRgpBmM" />
 
  
  
<style>
@import url("https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap");
*,
*:before,
*:after {
  box-sizing: border-box;
}

body,
html {
  height: 100%;
}

body {
  margin: 0;
  font-size: 16px;
  font-family: "Roboto", Arial, sans-serif;
  line-height: 1.4;
  color: #3C4858;
  background: #7E5BEF;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.apinix {
  width: 100%;
  max-width: 500px;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  align-content: center;
}
.apinix .apinix__title,
.apinix .apinix__subtitle,
.apinix .apinix__description,
.apinix .apinix__link {
  display: inline-flex;
  color: white;
  font-weight: bold;
  text-align: center;
  line-height: 1;
}
.apinix .apinix__title,
.apinix .apinix__description {
  font-size: 20px;
  opacity: 0.5;
}
.apinix .apinix__subtitle {
  margin: 5px 0;
  font-size: 50px;
}
.apinix .apinix__description {
  margin-bottom: 10px;
}
.apinix .apinix__link {
  align-items: center;
  justify-content: center;
  font-size: 10px;
  text-decoration: none;
}
.apinix .apinix__link .apinix__link__img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  margin: 0 5px;
}

.wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.wrapper.wrapper--top {
  height: auto;
  padding-bottom: 100px;
  justify-content: flex-start;
}
.wrapper.wrapper--top .apinix {
  padding-top: 100px;
}
.wrapper .block {
  width: 100%;
  max-width: 500px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 4px;
  background: white;
  transition: all 0.18s ease-in-out;
  box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.04), 0px 2px 6px rgba(0, 0, 0, 0.08), 0px 16px 24px rgba(0, 0, 0, 0.1), 0px 24px 32px rgba(0, 0, 0, 0.14);
}
.wrapper .block h4 {
  margin: 0;
  c.........完整代码请登录后点击上方下载按钮下载查看

网友评论0