如何做在两侧2个固定侧栏一个简单的接口?我有这样的:我该如何解决侧边栏的权利吗?以及当scrren为<1200-> sidebar-right displayn none
时如何添加过渡
html,
body {
width: 100%;
height: 100%;
}
.wrapper {
display: flex;
height: 100%;
}
.sidebar-left {
position: fixed;
width: 250px;
height: 100%;
background-color: blue;
}
.sidebar-right {
transition: all 1s;
width: 350px;
height: 100%;
background-color: blue;
}
.content {
width: calc(100% - 600px);
background-color: white;
margin-left: 250px;
}
@media (max-width: 1200px) {
.sidebar-right {
display: none;
}
.content {
width: calc(100% - 250px);
}
}
<div class="wrapper">
<div class="sidebar-left">
<p>a</p>
</div>
<div class="content">
<p>
Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem
<br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem
<br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>Lorem <br>
</p>
</div>
<div class="sidebar-right">
<p>a</p>
</div>
</div>
答案 0 :(得分:1)
修改后的答案
.main {
width: 80%;
height: 200px;
margin: auto;
padding: 10px;
}
.sidebar-left {
float: left;
width: 200px;
height: 100%;
background-color: blue;
}
.content {
float: left;
width: 200px;
height: 100%;
background-color: green;
}
.sidebar-right {
float: left;
width: 200px;
height: 100%;
background-color: yellow;
}
将您的HTML代码与这些类一起使用。
答案 1 :(得分:0)
要使两侧都有侧栏,请尝试以下操作:
.wrapper {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.sidebar-right {
transition: all 1s;
width: 350px;
height: 100%;
background-color: blue;
}
.content {
width: calc(100% - 600px);
background-color: white;
margin-left: 250px;
}
@media (max-width: 1200px) {
.sidebar-right {
display: none;
}
.content {
width: calc(100% - 250px);
}
}