gpt4 book ai didi

html - Internet Explorer 中的垂直滚动条

转载 作者:行者123 更新时间:2023-11-28 15:16:37 27 4
gpt4 key购买 nike

我试图确保此页面显示为 100% 高度和宽度,但在这样做时,如代码所示,出现滚动条。

在 Chrome 中,行为有所不同并且符合预期。看起来处理起来应该相当简单,但我似乎无法让它工作。

要重现该问题,只需在 IE 中运行此代码即可。

@import url('https://fonts.googleapis.com/css?family=Titillium+Web:300,700');
body,
html {
height: 100%;
padding: 0;
margin: 0;
font-family: 'Titillium Web', sans-serif;

}


body {
background: #F1F1F1 url('http://via.placeholder.com/1900');
background-size: cover;
}

.main-bg {
height: 100%;
width: 80%;
min-width: 500px;
position: absolute;
z-index: -9999;
}

.main-container {
height: 100%;
width: 80%;
min-width: 500px;
}

.large-only,
.small-only,
.tiny-only {
display: none;
}

.text-container {
position: absolute;
top: 50%;
left: 50%;
width: 100%;
transform: translate(-50%, -50%);
}

.text-container-parent {
position: relative;
}

@media screen and (min-width: 1280px) {
.large-only {
display: block;
}
.text-container-parent {
width: 55%;
}
.text-container {
padding-bottom: 8vh;
}
.text-word.massive {
font-size: 5.2vw;
letter-spacing: -5px;
}
body {
font-size: 1.68vw;
}
.button-div {
padding-top: 2.6vw;
}
}

@media screen and (min-width: 721px) and (max-width: 1279px) {
.small-only {
display: block;
}
.text-container-parent {
width: 80%;
}
.text-word.massive {
letter-spacing: -2px;
font-size: 7vw;
}
body {
font-size: 2.5vw;
}
.button-div {
padding-top: 3.5vw;
}
}

@media screen and (max-width: 720px) {
.tiny-only {
display: block;
}
.text-container-parent {
width: 100%;
}
.text-word.massive {
letter-spacing: -2px;
font-size: 12.2vw;
}
body {
font-size: 3.5vw;
}
.button-div {
padding-top: 6.1vw;
}
.text-container {
position: static;
transform: none!important;
margin: auto;
padding-top: 2em;
}
.title-row {
margin: auto;
}
.button-div {
margin: auto;
}
.logo-and-title {
margin: auto;
}
}

@media screen and (max-width: 500px) {
.main-container {
height: 100%!important;
width: 100%!important;
margin: auto!important;
min-width: inherit!important;
}
body {
background: #F1F1F1;
}

.main-bg {
min-width: inherit!important;
width: 100%;
}
}

.text-container-parent {
height: 100%;
}

.no-select {
user-select: none;
cursor: default;
-ms-user-select: none;
}

.no-select-buttons {
user-select: none;
-ms-user-select: none;
}

img.logo-large {
height: auto;
max-width: 100%;
width: 32vh;
max-height: 32vh;
text-align: center;
}

img.inline {
max-width: 1.5em;
max-height: 1.5em;
margin: -0.25em;
padding: 0 0.5em;
}

.text-word {
color: white;
}

.text-word.massive {
font-weight: 700;
}

.text-word.large {
font-weight: 300;
}

.text-word.error {
margin-left: -5px;
}

.text-word.four-zero-four {
color: #90B774;
}

.button-div {}

.button {
display: inline-block;
text-decoration: none;
color: white;
background: #586067;
margin: 0 0.75em 0.25em 0;
padding: 0.5em;
transition: all 0.2s ease;
}

.button:hover {
background: #3c444b;
transition: all 0.2s ease;
}

.button:active {
background: #607352;
transition: all 0.2s ease;
}


.block-level-div {
display: table;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<title>Error 404</title>
<link rel="stylesheet" href="CSS/404.min.css">
</head>
<body>
<div class="main-container">
<div class="svg-background">
<svg class='main-bg' viewBox="0 0 100 100" preserveAspectRatio="none">
<polygon points="0,0 0,100 55,100 100,0" style="fill: rgba(29, 37, 44, 0.9);" class="large-only" />
<polygon points="0,0 0,100 80,100 100,0" style="fill: rgba(29, 37, 44, 0.9);" class="small-only" />
<polygon points="0,0 0,100 100,100 100,0" style="fill: rgba(29, 37, 44, 0.9);;" class="tiny-only" />
</svg>
</div>
<div class="text-container-parent">
<div class="text-container">
<div style="margin: auto" class="block-level-div">
<div class="logo-and-title no-select block-level-div">
<img src="http://via.placeholder.com/300" class="no-select logo-large" />
<div class="title-row block-level-div">
<span class="text-word massive error">ERROR </span>
<span class="text-word massive four-zero-four">404</span>
</div>
</div>
<div class="text-word large no-select block-level-div">OOPS...Looks like you may have taken a wrong turn.</div>
<div class="text-word large no-select block-level-div">Don't worry, it happens to the best of us.</div>
<div class="button-div no-select-buttons block-level-div">
<a href="https://google.com.com/" class="button">Take Me Home! <img src="http://via.placeholder.com/300" class="inline" /></a>
<a href="mailto:me@google.com" class="button">Report A Problem</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

最佳答案

为了在 Internet Explorer 中隐藏滚动条,您所要做的就是将 overflow-y: hidden 添加到 body 中:

@import url('https://fonts.googleapis.com/css?family=Titillium+Web:300,700');
body,
html {
height: 100%;
padding: 0;
margin: 0;
font-family: 'Titillium Web', sans-serif;
}

body {
background: #F1F1F1 url('http://via.placeholder.com/1900');
background-size: cover;
overflow-y: hidden;
}

.main-bg {
height: 100%;
width: 80%;
min-width: 500px;
position: absolute;
z-index: -9999;
}

.main-container {
height: 100%;
width: 80%;
min-width: 500px;
}

.large-only,
.small-only,
.tiny-only {
display: none;
}

.text-container {
position: absolute;
top: 50%;
left: 50%;
width: 100%;
transform: translate(-50%, -50%);
}

.text-container-parent {
position: relative;
}

@media screen and (min-width: 1280px) {
.large-only {
display: block;
}
.text-container-parent {
width: 55%;
}
.text-container {
padding-bottom: 8vh;
}
.text-word.massive {
font-size: 5.2vw;
letter-spacing: -5px;
}
body {
font-size: 1.68vw;
}
.button-div {
padding-top: 2.6vw;
}
}

@media screen and (min-width: 721px) and (max-width: 1279px) {
.small-only {
display: block;
}
.text-container-parent {
width: 80%;
}
.text-word.massive {
letter-spacing: -2px;
font-size: 7vw;
}
body {
font-size: 2.5vw;
}
.button-div {
padding-top: 3.5vw;
}
}

@media screen and (max-width: 720px) {
.tiny-only {
display: block;
}
.text-container-parent {
width: 100%;
}
.text-word.massive {
letter-spacing: -2px;
font-size: 12.2vw;
}
body {
font-size: 3.5vw;
}
.button-div {
padding-top: 6.1vw;
}
.text-container {
position: static;
transform: none!important;
margin: auto;
padding-top: 2em;
}
.title-row {
margin: auto;
}
.button-div {
margin: auto;
}
.logo-and-title {
margin: auto;
}
}

@media screen and (max-width: 500px) {
.main-container {
height: 100%!important;
width: 100%!important;
margin: auto!important;
min-width: inherit!important;
}
body {
background: #F1F1F1;
}
.main-bg {
min-width: inherit!important;
width: 100%;
}
}

.text-container-parent {
height: 100%;
}

.no-select {
user-select: none;
cursor: default;
-ms-user-select: none;
}

.no-select-buttons {
user-select: none;
-ms-user-select: none;
}

img.logo-large {
height: auto;
max-width: 100%;
width: 32vh;
max-height: 32vh;
text-align: center;
}

img.inline {
max-width: 1.5em;
max-height: 1.5em;
margin: -0.25em;
padding: 0 0.5em;
}

.text-word {
color: white;
}

.text-word.massive {
font-weight: 700;
}

.text-word.large {
font-weight: 300;
}

.text-word.error {
margin-left: -5px;
}

.text-word.four-zero-four {
color: #90B774;
}

.button-div {}

.button {
display: inline-block;
text-decoration: none;
color: white;
background: #586067;
margin: 0 0.75em 0.25em 0;
padding: 0.5em;
transition: all 0.2s ease;
}

.button:hover {
background: #3c444b;
transition: all 0.2s ease;
}

.button:active {
background: #607352;
transition: all 0.2s ease;
}

.block-level-div {
display: table;
}
<!DOCTYPE html>
<html lang="en">

<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<title>Error 404</title>
<link rel="stylesheet" href="CSS/404.min.css">
</head>

<body>
<div class="main-container">
<div class="svg-background">
<svg class='main-bg' viewBox="0 0 100 100" preserveAspectRatio="none">
<polygon points="0,0 0,100 55,100 100,0" style="fill: rgba(29, 37, 44, 0.9);" class="large-only" />
<polygon points="0,0 0,100 80,100 100,0" style="fill: rgba(29, 37, 44, 0.9);" class="small-only" />
<polygon points="0,0 0,100 100,100 100,0" style="fill: rgba(29, 37, 44, 0.9);;" class="tiny-only" />
</svg>
</div>
<div class="text-container-parent">
<div class="text-container">
<div style="margin: auto" class="block-level-div">
<div class="logo-and-title no-select block-level-div">
<img src="http://via.placeholder.com/300" class="no-select logo-large" />
<div class="title-row block-level-div">
<span class="text-word massive error">ERROR </span>
<span class="text-word massive four-zero-four">404</span>
</div>
</div>
<div class="text-word large no-select block-level-div">OOPS...Looks like you may have taken a wrong turn.</div>
<div class="text-word large no-select block-level-div">Don't worry, it happens to the best of us.</div>
<div class="button-div no-select-buttons block-level-div">
<a href="https://google.com.com/" class="button">Take Me Home! <img src="http://via.placeholder.com/300" class="inline" /></a>
<a href="mailto:me@google.com" class="button">Report A Problem</a>
</div>
</div>
</div>
</div>
</div>
</body>

</html>

但是,问题的真正“根源”是您在两个 上都设置了 100%height bodyhtml,此外还向 .text-container 添加了转换以弥补这一点。我建议删除此规则,然后以特定宽度修改 .text-container 的填充:

@media screen and (min-width: 1280px) {
.text-container {
padding-top: 5%;
}
}

这可以从以下方面看出:

@import url('https://fonts.googleapis.com/css?family=Titillium+Web:300,700');
body,
html {
/*height: 100%;*/
padding: 0;
margin: 0;
font-family: 'Titillium Web', sans-serif;
}

body {
background: #F1F1F1 url('http://via.placeholder.com/1900');
background-size: cover;
}

.main-bg {
height: 100%;
width: 80%;
min-width: 500px;
position: absolute;
z-index: -9999;
}

.main-container {
height: 100%;
width: 80%;
min-width: 500px;
}

.large-only,
.small-only,
.tiny-only {
display: none;
}

.text-container {
/*
position: absolute;
top: 50%;
left: 50%;
width: 100%;
transform: translate(-50%, -50%);
*/
}

.text-container-parent {
position: relative;
}

@media screen and (min-width: 1280px) {
.text-container {
padding-top: 5%;
}
.large-only {
display: block;
}
.text-container-parent {
width: 55%;
}
.text-container {
padding-bottom: 8vh;
}
.text-word.massive {
font-size: 5.2vw;
letter-spacing: -5px;
}
body {
font-size: 1.68vw;
}
.button-div {
padding-top: 2.6vw;
}
}

@media screen and (min-width: 721px) and (max-width: 1279px) {
.small-only {
display: block;
}
.text-container-parent {
width: 80%;
}
.text-word.massive {
letter-spacing: -2px;
font-size: 7vw;
}
body {
font-size: 2.5vw;
}
.button-div {
padding-top: 3.5vw;
}
}

@media screen and (max-width: 720px) {
.tiny-only {
display: block;
}
.text-container-parent {
width: 100%;
}
.text-word.massive {
letter-spacing: -2px;
font-size: 12.2vw;
}
body {
font-size: 3.5vw;
}
.button-div {
padding-top: 6.1vw;
}
.text-container {
position: static;
transform: none!important;
margin: auto;
padding-top: 2em;
}
.title-row {
margin: auto;
}
.button-div {
margin: auto;
}
.logo-and-title {
margin: auto;
}
}

@media screen and (max-width: 500px) {
.main-container {
height: 100%!important;
width: 100%!important;
margin: auto!important;
min-width: inherit!important;
}
body {
background: #F1F1F1;
}
.main-bg {
min-width: inherit!important;
width: 100%;
}
}

.text-container-parent {
height: 100%;
}

.no-select {
user-select: none;
cursor: default;
-ms-user-select: none;
}

.no-select-buttons {
user-select: none;
-ms-user-select: none;
}

img.logo-large {
height: auto;
max-width: 100%;
width: 32vh;
max-height: 32vh;
text-align: center;
}

img.inline {
max-width: 1.5em;
max-height: 1.5em;
margin: -0.25em;
padding: 0 0.5em;
}

.text-word {
color: white;
}

.text-word.massive {
font-weight: 700;
}

.text-word.large {
font-weight: 300;
}

.text-word.error {
margin-left: -5px;
}

.text-word.four-zero-four {
color: #90B774;
}

.button-div {}

.button {
display: inline-block;
text-decoration: none;
color: white;
background: #586067;
margin: 0 0.75em 0.25em 0;
padding: 0.5em;
transition: all 0.2s ease;
}

.button:hover {
background: #3c444b;
transition: all 0.2s ease;
}

.button:active {
background: #607352;
transition: all 0.2s ease;
}

.block-level-div {
display: table;
}
<!DOCTYPE html>
<html lang="en">

<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<title>Error 404</title>
<link rel="stylesheet" href="CSS/404.min.css">
</head>

<body>
<div class="main-container">
<div class="svg-background">
<svg class='main-bg' viewBox="0 0 100 100" preserveAspectRatio="none">
<polygon points="0,0 0,100 55,100 100,0" style="fill: rgba(29, 37, 44, 0.9);" class="large-only" />
<polygon points="0,0 0,100 80,100 100,0" style="fill: rgba(29, 37, 44, 0.9);" class="small-only" />
<polygon points="0,0 0,100 100,100 100,0" style="fill: rgba(29, 37, 44, 0.9);;" class="tiny-only" />
</svg>
</div>
<div class="text-container-parent">
<div class="text-container">
<div style="margin: auto" class="block-level-div">
<div class="logo-and-title no-select block-level-div">
<img src="http://via.placeholder.com/300" class="no-select logo-large" />
<div class="title-row block-level-div">
<span class="text-word massive error">ERROR </span>
<span class="text-word massive four-zero-four">404</span>
</div>
</div>
<div class="text-word large no-select block-level-div">OOPS...Looks like you may have taken a wrong turn.</div>
<div class="text-word large no-select block-level-div">Don't worry, it happens to the best of us.</div>
<div class="button-div no-select-buttons block-level-div">
<a href="https://google.com.com/" class="button">Take Me Home! <img src="http://via.placeholder.com/300" class="inline" /></a>
<a href="mailto:me@google.com" class="button">Report A Problem</a>
</div>
</div>
</div>
</div>
</div>
</body>

</html>

希望对您有所帮助! :)

关于html - Internet Explorer 中的垂直滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47044020/

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