gpt4 book ai didi

html - 背景颜色不会拉伸(stretch) div 的全高

转载 作者:太空宇宙 更新时间:2023-11-04 01:30:36 25 4
gpt4 key购买 nike

我有一个部分包装了 2 个 div 的,一个是视频,另一个是文本 block 。在文本 block 中,我希望背景颜色 跨越 div 的高度,这似乎是视频高度的函数。我宁愿不使用绝对像素值来声明 div 的高度。 500px 的高度非常接近,但不可能使视频和文本 div 的顶部和底部边距完美对齐。

问题:有什么方法可以让文本div中的背景色在不声明高度的情况下跨越整个div吗?

由于包装器的黑色背景是这样做的,而且包装器或 div 都没有声明高度,所以似乎应该有办法。谢谢。

html {
background-color: black;
}

body {
width: 100%;
margin: 0 auto 0;
}

.container_white_space {
height: 50px;
background-color: white;
}

.container_white_space p {
text-indent: -9999px;
border: 0px;
margin: 0px;
}

.wrapper_video_and_text {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
width: 100%;
padding-top: 0px;
}

.video {
width: 50%;
}

.video_text {
width: 50%;
margin: auto;
overflow: hidden;
background: linear-gradient(to left, rgb(255, 255, 255), rgb(80, 70, 81));
}

.video_text p {
font-family: "europa", sans-serif;
font-size: 20px;
color: black;
line-height: 135%;
margin-left: 30%;
margin-right: 30%;
}
<!DOCTYPE HTML>
<html>
<head>
<script src="//content.jwplatform.com/libraries/YQ8opLwo.js"></script>
<script src="https://use.typekit.net/qkv6kzb.js"></script>
<script>
try {
Typekit.load({
async: true
});
} catch (e) {}
</script>
<script src="https://use.typekit.net/qkv6kzb.js"></script>
<script>
try {
Typekit.load({
async: true
});
} catch (e) {}
</script>
<meta charset="UTF-8">
<title>Barton's website</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<header>
</header>
<div class="container_white_space">
<p>text</p>
</div>
<section class="wrapper_video_and_text">
<div class="video">
<video width="100%" height="100%" autoplay="autoplay" loop="loop" muted="muted" preload>
<source src="https://bartonlewisfilm.com/08-LHBExcerpt.mp4" type="video/mp4">
</video>
</div>
<div class="video_text">
<p>text goes here text goes here text goes here text goes here text goes here text goes here text goes here text goes here text goes here text goes here text goes here text goes here.</p>
</div>
</section>
<div class="container_white_space">
<p>text</p>
</div>
</body>
</html>

最佳答案

您想从 .video-text 类中删除 margin:auto 并添加 min-height:100%

<!DOCTYPE HTML>
<html>
<head>

<meta charset="UTF-8">
<title>Barton's website</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--[if lt IE 9]>
<![endif]-->
<style>
html {
background-color: black;
}
body {
width: 100%;
margin: 0 auto 0;
}
.container_white_space {
height: 50px;
background-color: white;
}
.container_white_space p {
text-indent: -9999px;
border: 0px;
margin: 0px;
}
.wrapper_video_and_text {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
width: 100%;
padding-top: 0px;
}
.video {
width: 50%;
}
.video_text {
width: 50%;
overflow: hidden;
background: linear-gradient(to left, rgb(255, 255, 255), rgb(80, 70, 81));
min-height:100%;

}
.video_text p {
font-family: "europa",sans-serif;
font-size: 20px;
color: black;
line-height: 135%;
margin-left: 30%;
margin-right: 30%;
}
</style>
</head>
<body>
<header>
</header>
<div class="container_white_space">
<p>text</p>
</div>
<section class="wrapper_video_and_text">
<div class="video">
<video width="100%" height="100%" autoplay="autoplay" loop="loop" muted="muted" preload>
<source src="https://bartonlewisfilm.com/08-LHBExcerpt.mp4" type="video/mp4">
</video>
</div>
<div class="video_text">
<p>text goes here text goes here text goes here text goes here text goes here text goes here text goes here text goes here text goes here text goes here text goes here text goes here.</p>
</div>
</section>
<div class="container_white_space">
<p>text</p>
</div>
</body>
</html>

关于html - 背景颜色不会拉伸(stretch) div 的全高,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47171362/

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