目标
我的目标是让每个部分的移动版本正确显示。
问题
我遇到了这个烦人的问题:
全宽(一切都很好,看起来不错)
手机版(不好)
该部分在此处分开:
引导卡进入下一部分,它不应该这样做。
而且,在与我联系时,您可以看到引导卡位于:
HTML 和 CSS
/* ------------ PROJECTS ------------ */
#projects {
position: relative;
background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)) ,url('../img/_DSC0031.jpg');
background-position: center;
background-size: cover;
background-attachment: fixed;
height: 100vh;
}
#projects .title {
text-align: center;
color: #fff;
}
#projects h1{
font-size: 5rem;
padding-top: 5rem;
}
#projects .card {
margin-bottom: 1rem;
padding: 1rem;
transition: .5s;
}
#projects .card:hover {
background-color: #512da8;
color: #fff;
cursor: pointer;
}
/* ------------ Contact me ------------ */
#contact-me {
position: relative;
background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)) ,url('../img/IMG_1790.JPG');
background-position: center;
background-size: cover;
background-attachment: fixed;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
#contact-me form {
color: #fff;
background: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2));
padding: 25px;
}
#contact-me button {
background-color: #512da8 !important;
}
@media only screen and (max-width: 992px) {
#about-me .container {
position: absolute;
margin-top: 2rem;
margin-bottom: 5rem;
left: 0%;
}
#about-me video {
width: 100%;
height: 100%;
margin-right: 0rem;
object-position: right;
}
#about-me .text {
position: relative;
width: 100%;
}
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<!-- Main Layout-->
<main>
<section id="projects" data-aos="fade-in">
<div class="container ">
<div class="title">
<h1>PROJECTS</h1>
</div>
<hr class="hr-light mb-4">
<div class="row">
<div class="col-md-6 col-lg-4">
<div class="card text-center">
<video loop muted autoplay poster="img/videoframe.jpg" class="card-img-top">
<source src="video/Cest La Vie_Trim.mp4" type="video/mp4">
</video>
<div class="card-body">
<h5 class="card-title">Filmography</h5>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="card text-center">
<video loop muted autoplay poster="img/videoframe.jpg" class="card-img-top">
<source src="video/STUCCO III_Trim.mp4" type="video/mp4">
</video>
<div class="card-body">
<h5 class="card-title">Photography</h5>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="card text-center">
<video loop muted autoplay poster="img/videoframe.jpg" class="card-img-top">
<source src="video/A Badly Rolled J -2_Trim.mp4" type="video/mp4">
</video>
<div class="card-body">
<h5 class="card-title">Script Writing</h5>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="card text-center">
<video loop muted autoplay poster="img/videoframe.jpg" class="card-img-top">
<source src="video/Cest La Vie_Trim_2.mp4" type="video/mp4">
</video>
<div class="card-body">
<h5 class="card-title">Reviews</h5>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="contact-me" data-aos="fade-in">
<div class="container">
<form>
<h1>Contact me</h1>
<label>Full Name</label>
<div class="row">
<div class="col">
<input type="text" class="form-control" placeholder="First name">
</div>
<div class="col">
<input type="text" class="form-control" placeholder="Last name">
</div>
</div>
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email" aria-describedby="emailHelp" placeholder="e.g [email protected]">
</div>
<div class="form-group">
<label for="message">Your message</label>
<textarea class="form-control" id="message" rows="3" placeholder="Message..."></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</section>
</main>
<!-- Main Layout-->
问题
我做错了什么?在我的 css 中,我在制作这张尴尬的引导卡时出了什么问题?而且,将来 - 在分离部分时我应该记住什么?
您可以尝试在较小的设备上取消高度限制。
此刻的你限制了容器的大小#projects
和#contact-me
对100vh。
您可以在较小的屏幕上取消此限制(第一个示例#projects
)或使用最小高度(第二个示例#contact-me
)。
如果容器的大小是强制性的,则可以使用overflow: auto
,因此此容器内的内容也是可滚动的(第三个示例#projects2
)。
/*
https://images.unsplash.com/photo-1579546929518-9e396f3cc809?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjI0MX0&w=1000&q=80
*/
#projects {
position: relative;
background: url(https://images.unsplash.com/photo-1579546929518-9e396f3cc809?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjI0MX0&w=1000&q=80);
background-position: center;
background-size: cover;
background-attachment: fixed;
height: 100vh;
}
#projects2 {
position: relative;
background: url(https://images.unsplash.com/photo-1579546929518-9e396f3cc809?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjI0MX0&w=1000&q=80);
background-position: center;
background-size: cover;
background-attachment: fixed;
height: 100vh;
overflow:auto;
}
#projects .title {
text-align: center;
color: #fff;
}
#projects h1{
font-size: 5rem;
padding-top: 5rem;
}
#projects .card {
margin-bottom: 1rem;
padding: 1rem;
transition: .5s;
}
#projects .card:hover {
background-color: #512da8;
color: #fff;
cursor: pointer;
}
/* ------------ Contact me ------------ */
#contact-me {
position: relative;
background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)) ,url('../img/IMG_1790.JPG');
background-position: center;
background-size: cover;
background-attachment: fixed;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
#contact-me form {
color: #fff;
background: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2));
padding: 25px;
}
#contact-me button {
background-color: #512da8 !important;
}
@media only screen and (max-height: 1024px) {
#projects {
height: auto;
}
#about-me .container {
position: absolute;
margin-top: 2rem;
margin-bottom: 5rem;
left: 0%;
}
#about-me video {
width: 100%;
height: 100%;
margin-right: 0rem;
object-position: right;
}
#about-me .text {
position: relative;
width: 100%;
}
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<main>
<section id="projects" data-aos="fade-in">
<div class="container ">
<div class="title">
<h1>PROJECTS</h1>
</div>
<hr class="hr-light mb-4">
<div class="row">
<div class="col-md-6 col-lg-4">
<div class="card text-center">
<video loop muted autoplay poster="img/videoframe.jpg" class="card-img-top">
<source src="video/Cest La Vie_Trim.mp4" type="video/mp4">
</video>
<div class="card-body">
<h5 class="card-title">Filmography</h5>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="card text-center">
<video loop muted autoplay poster="img/videoframe.jpg" class="card-img-top">
<source src="video/STUCCO III_Trim.mp4" type="video/mp4">
</video>
<div class="card-body">
<h5 class="card-title">Photography</h5>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="card text-center">
<video loop muted autoplay poster="img/videoframe.jpg" class="card-img-top">
<source src="video/A Badly Rolled J -2_Trim.mp4" type="video/mp4">
</video>
<div class="card-body">
<h5 class="card-title">Script Writing</h5>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="card text-center">
<video loop muted autoplay poster="img/videoframe.jpg" class="card-img-top">
<source src="video/Cest La Vie_Trim_2.mp4" type="video/mp4">
</video>
<div class="card-body">
<h5 class="card-title">Reviews</h5>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="contact-me" data-aos="fade-in">
<div class="container">
<form>
<h1>Contact me</h1>
<label>Full Name</label>
<div class="row">
<div class="col">
<input type="text" class="form-control" placeholder="First name">
</div>
<div class="col">
<input type="text" class="form-control" placeholder="Last name">
</div>
</div>
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email" aria-describedby="emailHelp" placeholder="e.g [email protected]">
</div>
<div class="form-group">
<label for="message">Your message</label>
<textarea class="form-control" id="message" rows="3" placeholder="Message..."></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</section>
<section id="projects2" data-aos="fade-in">
<div class="container ">
<div class="title">
<h1>PROJECTS</h1>
</div>
<hr class="hr-light mb-4">
<div class="row">
<div class="col-md-6 col-lg-4">
<div class="card text-center">
<video loop muted autoplay poster="img/videoframe.jpg" class="card-img-top">
<source src="video/Cest La Vie_Trim.mp4" type="video/mp4">
</video>
<div class="card-body">
<h5 class="card-title">Filmography</h5>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="card text-center">
<video loop muted autoplay poster="img/videoframe.jpg" class="card-img-top">
<source src="video/STUCCO III_Trim.mp4" type="video/mp4">
</video>
<div class="card-body">
<h5 class="card-title">Photography</h5>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="card text-center">
<video loop muted autoplay poster="img/videoframe.jpg" class="card-img-top">
<source src="video/A Badly Rolled J -2_Trim.mp4" type="video/mp4">
</video>
<div class="card-body">
<h5 class="card-title">Script Writing</h5>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="card text-center">
<video loop muted autoplay poster="img/videoframe.jpg" class="card-img-top">
<source src="video/Cest La Vie_Trim_2.mp4" type="video/mp4">
</video>
<div class="card-body">
<h5 class="card-title">Reviews</h5>
</div>
</div>
</div>
</div>
</div>
</section>
</main>
<!-- Main Layout-->
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句