我正在尝试创建一个投资组合网站,并希望在旋转木马上有一个部分,该部分将显示我在 2x2 网格中完成的项目。我会将每个项目放入一张卡片中,当屏幕尺寸太小时,网格将变成 1x4,在各自的行上显示每个项目卡片。
我花了好几个小时翻阅 Bootstrap 文档以及一些 youtube 教程。虽然我能够在桌面屏幕尺寸上创建我正在寻找的卡片尺寸,但它在移动到移动设备时分崩离析并且看起来很糟糕。我尝试使用可以与“col”类相关联的各种属性,但它们似乎对我目前的情况没有任何帮助。我遇到了一些障碍,不知道还有什么其他资源可以帮助我解决这个问题。
索引.html
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap & other CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link rel="stylesheet" href="./index.css">
<title>Attempted Portfolio</title>
</head>
<body>
<div class="intro-container">
<div class="container">
<h1>
My Name The
<span class="txt-type" data-wait="3000" data-words ='["Developer", "Designer", "Creator"]'></span>
</h1>
<h2>Welcome to my website</h2>
</div>
</div>
<!-- Carousel -->
<div id="myCarousel" class="carousel slide"
data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#myCarousel"
data-slide-to="0" class="active"></li>
<li data-target="#myCarousel"
data-slide-to="1"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<div class="container">
<h1>About Me</h1>
<p>4 Buzzwords, Maybe a picture with brief about me, list skills/languages</p>
</div>
</div>
<div class="carousel-item">
<div class="container">
<h1>Projects</h1>
<!-- Project Showcase -->
<div class="row align-items-center">
<div class="col">
<div class="card">
<div class="card-body">
<h5 class="card-title">Project 1</h5>
<p class="cart-text">Project Info</p>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-body">
<h5 class="card-title">Project 2</h5>
<p class="cart-text">Project Info</p>
</div>
</div>
</div>
</div>
<div class="row align-items-center">
<div class="col">
<div class="card">
<div class="card-body">
<h5 class="card-title">Project 3</h5>
<p class="cart-text">Project Info</p>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-body">
<h5 class="card-title">Project 4</h5>
<p class="cart-text">Project Info</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#myCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#myCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<script src="app.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
索引.css
@import url('https://fonts.googleapis.com/css?family=Raleway:200,100,400');
body {
font-family: 'Raleway', sans-serif;
height: 100%;
color: #fff5f7;
overflow: scroll;
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
height: 100%;
padding: 0 3rem;
}
.intro-container {
background: #ffb7c5;
color: #fffce3;
height: 100vh;
}
.carousel-item {
background-color: #fff0f2;
color: #805258;
height: 100vh;
}
.box {
background-color: #FFBEAB;
margin: 60px;
padding: 20px;
margin: 20px;
}
.card {
background-color: #FFBEAB;
display: flex;
margin: 80px;
width: 20vh;
height: 100%;
}
h1, h2 {
font-weight: 200;
margin: 0.4rem;
}
h1 {
font-size: 2.5rem;
}
h2 {
font-size: 1.5rem;
}
/* Cursor Animation */
.txt-type > .txt {
border-right: 0.2rem solid #fff5f7;
}
@media(min-width: 1200px) {
h1 {
font-size: 3rem;
}
}
@media(max-width: 800px) {
.container {
padding: 0 1rem;
}
h1 {
font-size: 1.5rem;
}
}
@media(max-width: 500px) {
h1 {
font-size: 2rem;
}
h2 {
font-size: 1rem;
}
}