gpt4 book ai didi

html - 使用 flexbox 在每个旁边添加多个左右边栏

转载 作者:行者123 更新时间:2023-11-28 00:47:29 25 4
gpt4 key购买 nike

实际上,我一直在尝试自己解决这些问题,但我似乎无法弄清楚,我已经使用 flexbox 创建了一个布局,但我正在努力实现一些目标。让我说:-我有一个标题、导航和一个三列部分,其中包括主要部分和左右两侧的侧边栏,我想在以下位置添加更多侧边栏右边栏,但我似乎无法弄清楚,因为你知道我已经声明了三列 flex...

您可以在此处查看图像以了解要实现的目标 U can check the image here for understand what am trying to achieve

源代码在这里 www.codepen.io/enipx/details/dQmXKP

最佳答案

你可以在右边的 div .sidebarright 中包裹两个侧边栏

/* ===== Framework ===== */

html{
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
-o-box-sizing: border-box;
}

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

body{
background-color: #fdfafb;
height: 100vh;
/* border: 1px solid green; */
margin: 0 auto;
width: 100%;
}

.col-1{
width: 8.33%;
}
.col-2{
width: 16.66%;
}
.col-3{
width: 25%;
}
.col-4{
width: 33.33%;
}
.col-5{
width: 41.66%;
}
.col-6{
width: 50%;
}
.col-7{
width: 58.33%;
}
.col-8{
width: 66.66%;
}
.col-9{
width: 75%;
}
.col-10{
width: 83.33%;
}
.col-11{
width: 91.66%;
}
.col-12{
width: 100% ;
}


/* ===== Layout ===== */

#header{
margin: 10px;
height: 90px;
border-radius: 5px 5px 0 0;
background-color: rgba(160,194,227,0.8);
text-align: center;
color: white;
font-size: medium;
}

#nav{
margin: 10px;
margin-top: 0;
height: 40px;
border-radius: 0;
background-color: rgba(160,194,227,0.3);
text-align: center;
color: white;
font-size: medium;
}

.mainparent{
display: flex;
}

.sidebarright{
flex-basis: 16%;
order: 1;
}

.sidebarrightfirst{
margin: 10px;
margin-top: 0;
border-radius: 0;
background-color: rgba(160,194,227,0.5);
text-align: center;
color: white;
font-size: medium;
height: 195px;
}

.sidebarrightsecond{
margin: 10px;
margin-top: 0;
border-radius: 0;
background-color: rgba(160,194,227,0.5);
text-align: center;
color: white;
font-size: medium;
height: 195px;
}

.sidebarleft{
margin: 10px;
margin-top: 0;
border-radius: 0;
background-color: rgba(160,194,227,0.5);
text-align: center;
color: white;
font-size: medium;
flex-basis: 16%;
order: -1;
height: 400px;
}

.main{
margin-bottom: 10px;
margin-top: 0;
margin-right: 0;
margin-left: 0;
border-radius: 0;
background-color: rgba(160,194,227,0.5);
text-align: center;
color: white;
font-size: medium;
flex-basis: 68%;
height: 400px;
}

.imgport{
display: flex;
flex-wrap: wrap;
}

.imgport img {
width: calc(25% - 20px);
height: 200px;
margin: 10px;
margin-top: 0;
opacity: 0.8;
transition: 0.5s ease-in-out;
}

.imgport img:hover {
opacity: 1.0;
}

#footer{
margin: 10px;
margin-top: 0;
height: 200px;
border-radius: 0 0 5px 5px;
background-color: rgba(160,194,227,0.8);
text-align: center;
color: white;
font-size: medium;
}
<header id="header">
header
</header>

<nav id="nav">
nav
</nav>

<div class="mainparent">


<div class="sidebarright">
<aside class="sidebarrightfirst">
sidebarright
</aside>
<aside class="sidebarrightsecond">
sidebarright
</aside>
</div>

<aside class="sidebarleft">
sidebarleft
</aside>

<section class="main">
main
</section>

</div>

<div class="imgport">

<img src="https://images.unsplash.com/photo-1536276502222-b10f42bcf71e?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=6266a66ab254251150d738aad585fd36" alt="boxes">

<img src="https://images.unsplash.com/photo-1538592716926-9a321f0614ea?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=488b23073a233d23083f36b67c3bd769" alt="boxes">

<img src="https://images.unsplash.com/photo-1506798161991-ff979d14a391?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=7378c40e370c1207c6bca0d269c81818" alt="boxes">

<img src="https://images.unsplash.com/photo-1537203626302-cb08b9deb186?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=224379104368ef8280a06dfedda5c01b" alt="boxes">

<img src="https://images.unsplash.com/photo-1534256007535-8692ac6876cf?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=4c0f4f5d14175406c0ab97a8a0700950" alt="boxes">

<img src="https://images.unsplash.com/photo-1521405785232-7a56b029191e?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=c15f44bf62d0a5307c50150953fea8deg" alt="boxes">

<img src="https://images.unsplash.com/photo-1521405785232-7a56b029191e?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=c15f44bf62d0a5307c50150953fea8de" alt="boxes">

<img src="https://images.unsplash.com/photo-1534256007535-8692ac6876cf?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=4c0f4f5d14175406c0ab97a8a0700950" alt="boxes">
</div>

<footer id="footer">
footer
</footer>

关于html - 使用 flexbox 在每个旁边添加多个左右边栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53440436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com