如何自适应屏幕大小,比如我在一个大一点的屏幕页面打开或者手机打开就变了
求帮忙
@charset "utf-8";
html, body {
height: 100%;
width: 100%;
position: relative;
transition: .2s;
margin:0;
padding:0;
background-color: #EFE2E2;
}
header {
display: flex;
box-sizing: border-box;
flex-direction: row;
justify-content: flex-end;
align-items: center;
background-color: #C8AAAA;
font-size: 0.8rem;
font-family: monospace;
}
header > img {
margin: 10px auto 10px 10px;
}
header > nav > ul > li {
display: inline-block;
list-style-type: none;
padding: 0 1.252rem;
}
header > nav > ul > li > a {
text-decoration: none;
color: #333;
}
header > nav > ul > li > a:hover {
color: white;
}
.titleimg{
background-image: url("perth view.jpg");
height: 100vh;
background-repeat: no-repeat;
background-size: 1540px;
background-attachment: fixed;
width: 100%;
transition: 0.5s ease 0s;
animation: load 0.5s;
justify-content: flex-end;
}
.titleimg .title{
text-align: center;
width: 1540px;
padding:200px;
font-size: 100px;
font-weight: bolder;
color: floralwhite;
}
.main{
scroll-snap-type: y mandatory;
overflow: scroll;
overflow-x: hidden;
height: 100vh;
}
.sec{
height: 100vh;
width: 100vw;
scroll-snap-align: start;
}
.pt{
display: flex;
flex-direction: column;
height: 400px;
width: 250px;
float: left;
margin: 150px 0px 0px 105px;
background: rgba(219, 235, 241,0.8);
box-shadow: 0 0 15px rgb(59, 73, 95);
border-radius: 15px;
overflow: hidden;
scroll-snap-align: start;
transition: all 0.5s ease 0s;
}
.pt:hover{
cursor: pointer;
transform: scale(1.05);
}
.imghid{
overflow: hidden;
}
.part1 .img{
background-image: url("quokka.jpg");
}
.part2 .img{
background-image: url("kings park.png");
}
.part3 .img{
background-image: url("swan river.png");
}
.pt .img{
height: 190px;
width: 250px;
background-size: cover;
background-position: 0px -30px;
transition: all 0.5s ease 0s;
opacity: 0.8;
}
.pt .img:hover{
transform: scale(1.1);
}
.pt .txt{
height: 310px;
width: 200px;
overflow: hidden;
display: flex;
flex-direction: column;
margin: auto;
}
.pt .txt h1{
text-align: center;
font-size: 3em;
color: rgb(28, 44, 68);
height: 30px;
line-height: 30px;
}
.pt .txt p{
margin-top: -2px;
text-align: center;
font-family:Lucida Sans;
word-wrap: break-word;
color: rgb(114, 182, 202);
}
@keyframes load{
0%{
background-position-y: 50px;
opacity: 0;
}
100%{
background-position-y: 0px;
opacity: 1;
}
}