gpt4 book ai didi

html - 全高侧边栏和内容区域在较小的设备屏幕上中断

转载 作者:行者123 更新时间:2023-11-28 15:04:47 24 4
gpt4 key购买 nike

是否可以解决以下问题:在较小的设备屏幕上,边栏和内容区域的高度均为 100%?鉴于代码,我很难解决这个问题。

我的目标是创建侧边栏和内容区域。侧边栏应该是固定宽度的,在较小的设备上占据整个宽度。滚动内容时侧边栏是粘性的。

我正在使用 Bootstrap 4。

谢谢

代码:

<!doctype html>
<html lang="en" class="h-100">

<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Hello, world!</title>
<link href="../Assets/CSS/Master3-style.css" rel="stylesheet" />
<style>
html,
body {
color: white;
}

.sidebar {
background-color: aliceblue;
padding-right: 20px;
padding-left: 20px;
padding-top: 40px;
}

.logo {
margin-bottom: 40px;
max-width: 215px;
}

.logo-wrapper {
text-align: center;
}

.main {
background-color: antiquewhite;
color: black;
}

.sidebar-nav {
background-color: cadetblue;
max-width: 200px;
margin: 0 auto;
}

.left {
float: left;
width: 300px;
height: 100%;
background-image: linear-gradient(180deg, #00607a 0%, #006e73 100%);
padding-bottom: 40px;
}

.right {
float: right;
width: calc(100% - 300px);
background: yellow;
height: 100%;
}

@media only screen and (max-width: 768px) {
.left {
float: none;
height: auto;
width: 100%;
}
.right {
float: none;
width: 100%;
height: auto;
}
}
</style>
</head>

<body class="h-100">
<div class="h-100">
<div class="h-100">
<div class="sidebar left">
<div class="sticky-top">
<div class="logo-wrapper">
<img class="logo" src="http://logosvg.com/wp-content/uploads/2016/08/logosvgcom.png" />
</div>
<ul class="sidebar-nav">
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
<li><a>Link</a></li>
</ul>
</div>
</div>
<div class="main right">
<div class="container">

<div class="row">
<div class="col-12">
<p>
What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type
specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking
at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web
page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose
(injected humour and the like). Where does it come from? Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock,
a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable
source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance.
The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de
Finibus Bonorum et Malorum" by Cicero a
</p>
</div>
</div>
</div>
</div>
</div>

</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>

</html>

enter image description here

运行@MinIsNghia 代码,我遇到了两个问题,我想弄清楚: enter image description here

最佳答案

我不得不添加 overflow: auto;在 .sidebar 和 .main 上。

关于html - 全高侧边栏和内容区域在较小的设备屏幕上中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59086011/

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