gpt4 book ai didi

html - 隐藏滚动条

转载 作者:行者123 更新时间:2023-11-28 05:47:58 26 4
gpt4 key购买 nike

我正在创建一个投资组合网站,我试图隐藏我的滚动条以使其看起来很专业。但是,我在网上找不到任何解决方案,例如 .element::-webkit-scrollbar { width: 0 !important } , seamless="seamless" ,或任何 overflow: hidden变体(无论如何都无法使用,因为我仍然希望能够滚动),似乎有效。

我不确定应该包含我的 HTML 的哪一部分,所以这里是全部:

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

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

<link href='css/fonts.css' rel="stylesheet" type="text/css">
<link href='css/font-awesome.min.css' rel="stylesheet" type="text/css">
<link href='css/normalize.css' rel="stylesheet" type="text/css">
<link href='css/style.css' rel="stylesheet" type="text/css">
<link rel="icon" href="img/Logo.ico">

<title>*my name*</title>
</head>

<body>
<nav class="fixed-nav-bar">
<ul id="left-align-menubar">
<li class="nav-button"><a href="#main" class="nav-button-link">*my name*</a></li>
</ul>
<ul id="right-align-menubar">
<li class="nav-button"><a href="#math-showcase" class="nav-button-link">Math Work</a></li>
<li class="nav-button"><a href="#lang-showcase" class="nav-button-link">Language Work</a></li>
<li class="nav-button"><a href="#tech-showcase" class="nav-button-link">Tech Work</a></li>
<li class="nav-button"><a href="#art-showcase" class="nav-button-link">Art Pieces</a></li>
<li class="nav-button"><a href="#sci-showcase" class="nav-button-link">Science Work</a></li>
<li class="nav-button"><a href="#pro-showcase" class="nav-button-link">Professional Work</a></li>
</ul>
</nav>
<div class="main-content" id="main">
<div align="center" class="main-title">
<h1>*my name*</h1></div>
<div class="container showcase-div" id="math-showcase">
<img src="img/Math.jpg">
<a href="" class="showcase-collapse" id="math"><h2>Mathematics Work <span id="math-showcase-arrow" class="fa fa-angle-double-right fa-lg"></span></h2></a>
<div class="showcase-dropdown" id="math-dropdown">
<div>
<a href="" class="overlay-show" id="kiteheight">
<p>Kite Height Report</p>
</a>
</div>
<div>
skljhsldkjfh
</div>
<div>
skljhlkjh
</div>
</div>
</div>
<div class="container showcase-div" id="lang-showcase">
<img src="img/Math.jpg">
<a href="" class="showcase-collapse" id="lang"><h2>Language Work <span id="lang-showcase-arrow" class="fa fa-angle-double-right fa-lg"></span></h2></a>
<div class="showcase-dropdown" id="lang-dropdown">
<div>
skdjhfs
</div>
<div>
skljhsldkjfh
</div>
<div>
skljhlkjh
</div>
</div>
</div>
<div class="container showcase-div" id="tech-showcase">
<img src="img/Math.jpg">
<a href="" class="showcase-collapse" id="tech"><h2>Technological Work <span id="tech-showcase-arrow" class="fa fa-angle-double-right fa-lg"></span></h2></a>
<div class="showcase-dropdown" id="tech-dropdown">
<div>
skdjhfs
</div>
<div>
skljhsldkjfh
</div>
<div>
skljhlkjh
</div>
</div>
</div>
<div class="container showcase-div" id="art-showcase">
<img src="img/Math.jpg">
<a href="" class="showcase-collapse" id="art"><h2>Artistic Pieces <span id="art-showcase-arrow" class="fa fa-angle-double-right fa-lg"></span></h2></a>
<div class="showcase-dropdown" id="art-dropdown">
<div>
skdjhfs
</div>
<div>
skljhsldkjfh
</div>
<div>
skljhlkjh
</div>
</div>
</div>
<div class="container showcase-div" id="sci-showcase">
<img src="img/Math.jpg">
<a href="" class="showcase-collapse" id="sci"><h2>Science Work <span id="sci-showcase-arrow" class="fa fa-angle-double-right fa-lg"></span></h2></a>
<div class="showcase-dropdown" id="sci-dropdown">
<div>
skdjhfs
</div>
<div>
skljhsldkjfh
</div>
<div>
skljhlkjh
</div>
</div>
</div>
<div class="container showcase-div" id="pro-showcase">
<img src="img/Math.jpg">
<a href="" class="showcase-collapse" id="pro"><h2>Professional Work <span id="pro-showcase-arrow" class="fa fa-angle-double-right fa-lg"></span></h2></a>
<div class="showcase-dropdown" id="pro-dropdown">
<div>
skdjhfs
</div>
<div>
skljhsldkjfh
</div>
<div>
skljhlkjh
</div>
</div>
</div>
</div>
<div class="overlay">
<span class="fa fa-close fa-2x" id="overlay-close"></span></a>
</div>
<footer>
&copy; *my name*. All rights reserved. This website was built from the ground up by *my name* to showcase his portfolio. The website itself is part of the portfolio.
</footer>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="js/script.js" type="text/javascript" charset="utf-8"></script>
</body>

</html>

这是我使用的 CSS,包括目前向我建议的解决方案:

/*********************************
TEXT STYLING
*********************************/

* {
text-rendering: optimizeLegibility;
-webkit-font-smoothing: subpixel-antialiased;
-moz-osx-font-smoothing: grayscale;
}
h1 {
margin: 0;
padding: 2%;
}
.main-title {
font-size: 2em;
font-family: 'voltaire';
margin-top: 50px;
}
a, a:before, a:after {
text-decoration: none;
color: black;
}
h2 {
text-align: center;
}

/*********************************
NAV BAR STYLING
*********************************/

.nav-button:hover {
background-color: rgb(217, 217, 217);
height: 50px;
margin-top: 0;
}
.nav-button {
list-style: none;
display: inline-block;
}
.nav-button-link {
display: inline-block;
padding: 15px;
height: 20px;
}
#right-align-menubar {
top: 0;
right: 0;
display: inline-block;
position: absolute;
margin: 0;
vertical-align: middle;
}
#left-align-menubar {
top: 0;
left: 0;
display: inline-block;
position: absolute;
margin: 0;
vertical-align: middle;
padding-left: 0px;
}
.fixed-nav-bar {
font-weight: 500;
font-size: 1em;
position: fixed;
top: 0;
width: 100%;
height: 50px;
background-color: white;
z-index: 100;
}

/*********************************
BODY STYLING
*********************************/

body {
margin: 0;
font-family: 'nerislight';
background-color: white;
color: black;
}
footer {
background-color: black;
color: white;
padding: 10px;
}

/*********************************
SHOWCASE AND OVERLAY STYLING
*********************************/

.showcase-div img {
width: 100%;
border-top: 1px solid black;
border-bottom: 1px solid black;
}
.showcase-div {
position: relative;
}
.showcase-dropdown {
background-color: black;
display: none;
}
.showcase-dropdown div {
display: inline-block;
width: 33%;
margin: 0;
text-align: center;
}
.overlay-show p {
font-size: 1.25em;
color: white;
padding: 10px 0;
margin: 0;
}
#overlay-close {
position: fixed;
top: 10px;
right: 10px;
color: black;
z-index: 200;
}
.overlay {
display: none;
background-color: rgba(255, 255, 255, 0.9);
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 100;
overflow-y: scroll;
width: 100%;
padding: 0;
}
.document-embed {
height: 100%;
width: 100%;
}
.document p {
color: black;
margin: 0;
padding: 10px;
}

/*********************************
MISCELLANEOUS STYLING
*********************************/

body {
overflow: hidden;
}

/*********************************
ANIMATIONS
*********************************/

@-webkit-keyframes rotate {
from {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
to {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
@-webkit-keyframes rotateBack {
from {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
to {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(90deg);
}
}
@keyframes rotateBack {
from {
transform: rotate(90deg);
}
to {
transform: rotate(0deg);
}
}

这是我的 JavaScript,由于 overflow: hidden 而被破坏的部分:

$('#main').animate({
scrollTop: target.offset().top - 50
}, 1000);

通常,它有 html, body而不是 #main , 但这是向我建议的,我想知道为什么它不起作用以及我的错误是什么。

可能还值得一提的是,该网站还远未完成,欢迎您就改进代码提出任何建议。另外,我确实知道到处都有许多其他问题几乎与这个问题完全相同,但正如我所说,没有一个能回答我的问题。提前致谢!

最佳答案

您是否尝试过将 overflow:hidden 添加到 css 的 body 属性?这通常是我失败的地方。

关于html - 隐藏滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37505763/

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